• 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
  • Paul Clapham
  • Ron McLeod
  • Tim Cooke
  • Junilu Lacar
Sheriffs:
  • Rob Spoor
  • Devaka Cooray
  • Jeanne Boyarsky
Saloon Keepers:
  • Jesse Silverman
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Jj Roberts
  • Al Hobbs
  • Piet Souris

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!
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic