Results 1 to 3 of 3
  1. #1
    tola.ch2004 is offline Member
    Join Date
    Jul 2007
    Location
    Fairfield, IA 52557
    Posts
    2
    Rep Power
    0

    Default Problem with "GregorianCalendar"

    I initialize object of Gregorian class by the following code:
    Java Code:
    GregorianCalendar greCal = new GregorianCalendar(2000, 2, 1);
    And display it by the following code:
    Java Code:
    System.out.println(greCal.getTime().getMonth() + "/" + greCal.getTime().getDate() + "/" + greCal.getTime().getYear());
    Asa result I got:
    2/1/100 (It is Wrong!)
    It should be 2/1/2000

    Anyone please tell me why?:)

  2. #2
    susan is offline Member
    Join Date
    Jul 2007
    Posts
    44
    Rep Power
    0

    Default

    Try with this code:
    Java Code:
    DateFormat dateFormat = DateFormat.getDateInstance();
    Date date = dateFormat.parse("2000-01-02");
    
    GregorianCalendar gregorianCalendar = new GregorianCalendar();
    gregorianCalendar.setTime(date);

  3. #3
    tola.ch2004 is offline Member
    Join Date
    Jul 2007
    Location
    Fairfield, IA 52557
    Posts
    2
    Rep Power
    0

    Default

    Yes, it worked. Thank guy.

    However it made me feel uncomfortable with this GregorianCalendar.

Similar Threads

  1. Hwlp with "Open", "Save", "Save as..."
    By trill in forum New To Java
    Replies: 3
    Last Post: 11-02-2010, 09:26 AM
  2. "Displayed tab width" problem...
    By Petike in forum Eclipse
    Replies: 0
    Last Post: 03-17-2008, 09:39 PM
  3. I have a problem with variable "i"
    By silvia in forum New To Java
    Replies: 2
    Last Post: 08-07-2007, 11:05 PM
  4. Replies: 1
    Last Post: 07-27-2007, 10:59 PM
  5. Replies: 1
    Last Post: 07-25-2007, 10:55 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
  •