• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Date class question

 
Rebecca Pickett
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I create a new java.util.Date class object with a long parameter, I should get this according to all the documentation I've read:
January 1, 1970, 00:00:00 GMT
BUT, I'm getting December 31, 1969, 18:00:00 CST when I print it out. Is this time-zone compensation normal??
 
tony hutcheson
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have a guess. Do you live in the Central time zone? Because
January 1, 1970, 00:00:00 GMT
is the same as
December 31, 1969, 18:00:00 CST
It then adjusted for the time zone on your computer.
Hope that helps.
 
Rebecca Pickett
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yep, sure do and that's what I figured it was doing.
I was just surprised that it was compensating for Time Zone and not giving the real "epoch" in GMT.
 
Janna Lockhart
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's part of the portability of Java that it adjusts for the time zone that you're in. Notice the time stamps here at the java ranch on our posts? They accurately display the time stamp according to your time zone rather than the time zone of each user so that it's a more accurate view of the relative timing of each post!
 
Rebecca Pickett
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well that makes perfect sense, java portability-wise. Thanks for helping me see the light!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic