• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Calendar Output

 
AnuragSingh Kumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Saloon Keeper
Posts: 15354
39
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
AnuragSingh Kumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


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
Posts: 160
IntelliJ IDE Ubuntu VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
AnuragSingh Kumar
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Oh!! Sorry for that.
And thanks again for the help
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic