Problem with Gregorian Calendar hour of day in java

Posted by Leanne C on Stack Overflow See other posts from Stack Overflow or by Leanne C
Published on 2010-04-24T02:28:20Z Indexed on 2010/04/24 2:33 UTC
Read the original article Hit count: 362

Filed under:
|
|
|

hi,

I'm using a Gregorian Calendar to set a specific date and time to an application using the set function of the Gregorian Calendar. When i use the getTime() method, it gives me the right output however when i try to access the Hour_Of_Day and Minute it gives a wrong number.

    Calendar time = new GregorianCalendar();
    time.set(2010, Calendar.JANUARY, 1, 7, 20,0);       
    hour = time.HOUR_OF_DAY;
    minute = time.MINUTE; 

The hour gives an output of 11 and the minute gives an a value of 12.
Any suggestions on how to fix this? Thanks

© Stack Overflow or respective owner

Related posts about java

Related posts about gregorian-calendar