This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Beginning Java and the fly likes painful java.util.Date bug Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "painful java.util.Date bug" Watch "painful java.util.Date bug" New topic
Author

painful java.util.Date bug

aulo aasmaa
Greenhorn

Joined: Aug 06, 2001
Posts: 15

returns me the GMT time, even though I am located in GMT+2.
If my desktop clock shows 8:58, then the previous statement prints out 6:58.
Now where does this bug hide?
OK!
AUlo
Sunetra Saha
Ranch Hand

Joined: Feb 25, 2001
Posts: 77
I think you have to use the DateFormat class in java.text to format the date to your local time/date format.
Chad McGowan
Ranch Hand

Joined: May 10, 2001
Posts: 265
Make sure your locale is set correctly in your JVM. Use:
System.out.println(Locale.getDefault());
to see where the JVM thinks you are...
aulo aasmaa
Greenhorn

Joined: Aug 06, 2001
Posts: 15
Tnx, I have all the system keys in front of me:

The system kept counting with GMT as long as I made the default locale to GMT+2. It works fine now and all dates are displayed correctly in my JTable.
Tnx to everybody!
OK!
AUlo
 
Consider Paul's rocket mass heater.
 
subject: painful java.util.Date bug