File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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 Android Security Essentials Live Lessons this week in the Android 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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: painful java.util.Date bug
 
Similar Threads
problem while inserting date field in oracle data base
How to convert Date.toString back to Date
how to convert unix stamp to date?
Iplanet showing system date + 5:30 hrs
Null Pointer exception while reading the property file in WAS-5