Results 1 to 4 of 4
Thread: Calendar Class Problem
- 12-22-2010, 03:22 PM #1
Member
- Join Date
- Dec 2010
- Posts
- 1
- Rep Power
- 0
Calendar Class Problem
I'm trying to make an application to keep track of your appointments.
There are 2 classes, an Appointment class and a Calender class.
The Appointment class doesn't really matter for this question, so i'll just add the constructor of the Calender class.
The problem is I can't alter the date, and I need to do so for some of my methods.Java Code:public class Calender { private ArrayList<Appointment> appointments; private Calendar cal; private int date; private int month; private int year; public Calender() { appointments = new ArrayList<Appointment>(); cal = Calendar.getInstance(); this.date = cal.get(Calendar.DATE); this.year = cal.get(Calendar.YEAR); this.month = cal.get(Calendar.MONTH)+1;
simple example;
i also tried, this.cal.roll(Calendar.DATE, true) and this.cal.set.(Calendar.DATE, 23)Java Code:public void addDay() { this.cal.add(Calendar.DATE, 1); }
asked my teacher why this doesn't work, but he doesn't seem to know either..
edit: I imported
import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.GregorianCalendar;Last edited by Thomas338; 12-22-2010 at 03:30 PM.
- 12-22-2010, 03:45 PM #2
If you want help, you'll have to provide an SSCCE that demonstrates the problem. In other words, it should be as little code as possible while still being runnable (by simply copying and pasting the whole thing) and demonstrating the problematic behavior.
- 12-22-2010, 06:42 PM #3
Member
- Join Date
- Oct 2010
- Posts
- 63
- Rep Power
- 0
What you are showing will work if it is all in the right place. You need to show how you are calling it and the response you get.Java Code:The problem is I can't alter the date, and I need to do so for some of my methods.
- 12-23-2010, 09:24 AM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,476
- Rep Power
- 16
What are you trying this on?
Your Calender object, or a Calendar object?
From what you've posted your Calender class does not have an add() method, or a roll() method or a set() method.
Also when posting a problem you need to tell us the problem, including any error messages and stack traces you get.
Similar Threads
-
Please help ...!!Calendar class
By kalyana in forum New To JavaReplies: 2Last Post: 10-10-2010, 08:25 AM -
plz help me with this class, calendar
By hamed in forum New To JavaReplies: 6Last Post: 09-06-2010, 10:58 PM -
How to use Calendar class
By JavaBean in forum Java TipReplies: 1Last Post: 06-26-2008, 03:09 PM -
How to set values with Calendar class ?
By mohiit in forum New To JavaReplies: 3Last Post: 05-14-2008, 04:21 AM -
How to use Calendar class
By Java Tip in forum java.utilReplies: 0Last Post: 04-04-2008, 02:33 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks