| Author |
Calendar Output
|
AnuragSingh Kumar
Greenhorn
Joined: Nov 24, 2011
Posts: 5
|
|
Hi
I have a code as
where i try to set time in the format specified.
But when i do a print of cal i get some values which are different from my set value as
HOUR_OF_DAY=13, [OK]
MINUTE=10, [Not OK]
SECOND=12, [Not OK]
MILLISECOND=17 [Not OK]
.
Also 5th jan 2011 was wed day but the output was
DAY_OF_WEEK=2
I cannt get where does this difference come from. Can i get some help please..
|
 |
Jesper de Jong
Java Cowboy
Bartender
Joined: Aug 16, 2005
Posts: 11642
|
|
One thing that is wrong is that you define the milliseconds value with 6 digits. Milliseconds are thousandths of a second - it can have at most 3 digits (because when it goes over 1000, it's one second).
301017 milliseconds is 301 seconds and 17 milliseconds. And that explains exactly what's happening here: the time is 13 hours, 5 minutes, 11 seconds plus 301 seconds and 17 milliseconds = 13:05:11 plus 5 minutes, 1 second, 17 ms = 13:10:12.017 -> so hours = 13, minutes = 10, seconds = 12, ms = 17, exactly what you're getting.
|
Java Beginners FAQ - JavaRanch SCJP FAQ - The Java Tutorial - Java SE 7 API documentation
Scala Notes - My blog about Scala
|
 |
AnuragSingh Kumar
Greenhorn
Joined: Nov 24, 2011
Posts: 5
|
|
Thank you Jesper
This solves the minute and second problem . But i still have this DAY_OF_WEEK=2 which should be 4.
|
 |
Riaan Nel
Ranch Hand
Joined: Apr 23, 2009
Posts: 151
|
|
AnuragSingh Kumar wrote:
Thank you Jesper
This solves the minute and second problem . But i still have this DAY_OF_WEEK=2 which should be 4.
Look at the code you posted - are you sure that you want to be looking at the year 2111, rather than 2011?
|
"The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore, all progress depends on the unreasonable man." - George Bernard Shaw
|
 |
AnuragSingh Kumar
Greenhorn
Joined: Nov 24, 2011
Posts: 5
|
|
Oh!! Sorry for that.
And thanks again for the help
|
 |
 |
|
|
subject: Calendar Output
|
|
|