Results 1 to 4 of 4
  1. #1
    Thomas338 is offline Member
    Join Date
    Dec 2010
    Posts
    1
    Rep Power
    0

    Default 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.

    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;
    The problem is I can't alter the date, and I need to do so for some of my methods.

    simple example;

    Java Code:
       public void addDay() {
           this.cal.add(Calendar.DATE, 1);
       }
    i also tried, this.cal.roll(Calendar.DATE, true) and this.cal.set.(Calendar.DATE, 23)
    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.

  2. #2
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,963
    Rep Power
    8

    Default

    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.

  3. #3
    hosscomp is offline Member
    Join Date
    Oct 2010
    Posts
    63
    Rep Power
    0

    Default

    Java Code:
    The problem is I can't alter the date, and I need to do so for some of my methods.
    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.

  4. #4
    Tolls is online now Moderator
    Join Date
    Apr 2009
    Posts
    12,009
    Rep Power
    20

    Default

    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

  1. Please help ...!!Calendar class
    By kalyana in forum New To Java
    Replies: 2
    Last Post: 10-10-2010, 08:25 AM
  2. plz help me with this class, calendar
    By hamed in forum New To Java
    Replies: 6
    Last Post: 09-06-2010, 10:58 PM
  3. How to use Calendar class
    By JavaBean in forum Java Tip
    Replies: 1
    Last Post: 06-26-2008, 03:09 PM
  4. How to set values with Calendar class ?
    By mohiit in forum New To Java
    Replies: 3
    Last Post: 05-14-2008, 04:21 AM
  5. How to use Calendar class
    By Java Tip in forum java.util
    Replies: 0
    Last Post: 04-04-2008, 02:33 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •