• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Date class question

 
Greenhorn
Posts: 15
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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??
 
Ranch Hand
Posts: 38
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Greenhorn
Posts: 24
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Well that makes perfect sense, java portability-wise. Thanks for helping me see the light!
 
If I'd had more time, I would have written a shorter letter. -T.S. Eliot such a short, tiny ad:
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic