Results 1 to 3 of 3
- 08-07-2007, 08:34 AM #1
Member
- Join Date
- Aug 2007
- Posts
- 5
- Rep Power
- 0
DataObject with the time given by me
c.set(Calendar.HOUR,21);
c.set(Calendar.MINUTE,46);
c.set(Calendar.SECOND,20);
Date timeToRun=c.getTime();
System.out.println("date="+timeToRun);
o/p:date=Tue Aug 07 09:46:20 PDT 2007
Why is it taking the next day(In my example my todays date is aug06) date and the time specified by me.It need to be the current date and the time specified by me......... right? I see the time is set properly but when coming to date it is giving me the next day date.
Then how to get the date object witn the current date and with the time specified by me ?
Ragards
navap
- 08-07-2007, 02:03 PM #2
Member
- Join Date
- Jul 2007
- Location
- England, Bath
- Posts
- 47
- Rep Power
- 0
You need to use HOUR_OF_DAY instead of HOUR as you are trying to use the 24 hour clock.
HOUR is specified in the javadoc as :
Field number for get and set indicating the hour of the morning or afternoon. HOUR is used for the 12-hour clock. E.g., at 10:04:15.250 PM the HOUR is 10.
so it is rolling the time forwards by 12 hours from what you requested hence 09 the next day instead of 21 the right day.
Hope this makes sense,
Shane.
- 08-07-2007, 06:33 PM #3
Member
- Join Date
- Aug 2007
- Posts
- 5
- Rep Power
- 0
Similar Threads
-
Hello, first time here.
By ludragon in forum IntroductionsReplies: 2Last Post: 01-03-2008, 05:03 AM -
help with dates and time
By osval in forum New To JavaReplies: 3Last Post: 12-12-2007, 12:41 PM -
Method execution time
By javaplus in forum Advanced JavaReplies: 3Last Post: 11-26-2007, 09:51 AM -
Time method
By carderne in forum New To JavaReplies: 5Last Post: 11-05-2007, 09:34 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks