This week's giveaway is in the Android forum.
We're giving away four copies of Android Security Essentials Live Lessons and have Godfrey Nolan on-line!
See this thread for details.
The moose likes Beginning Java and the fly likes Date class question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Android Security Essentials Live Lessons this week in the Android forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Date class question" Watch "Date class question" New topic
Author

Date class question

Rebecca Pickett
Greenhorn

Joined: Aug 16, 2000
Posts: 15
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

Joined: Dec 08, 2000
Posts: 38
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

Joined: Aug 16, 2000
Posts: 15
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

Joined: Dec 21, 2000
Posts: 24
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!


- Janna
Rebecca Pickett
Greenhorn

Joined: Aug 16, 2000
Posts: 15
Well that makes perfect sense, java portability-wise. Thanks for helping me see the light!
 
Don't get me started about those stupid light bulbs.
 
subject: Date class question
 
Similar Threads
convert datetime from EST to PST
SEVERE: BAD packet signature 200,SEVERE: Caught exception (java.lang.NullPointerException)
Joda DateTime
Time conversion question
dynamically expand and collapse table rows