permaculture playing cards*
The moose likes Java in General and the fly likes Date.compareTo : misbehaviour on linux environment? 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 » Java in General
Bookmark "Date.compareTo : misbehaviour on linux environment?" Watch "Date.compareTo : misbehaviour on linux environment?" New topic
Author

Date.compareTo : misbehaviour on linux environment?

vishwanath nadimpally
Ranch Hand

Joined: Jan 25, 2005
Posts: 116
I have this piece of code:



Is Date.compareTo() unreliable?
Jim Yingst
Wanderer
Sheriff

Joined: Jan 30, 2000
Posts: 18671
[vishwanath]: Is Date.compareTo() unreliable?

Not as far as I know. I think the most likely causes of your problem here are either: (a) one of your machines has its system clock set incorrectly, or (b) the two machines are using different TimeZones or Locales, which would affect how they interpret the endDate. I recommend adding a few lines of code to see what's going on:


"I'm not back." - Bill Harding, Twister
vishwanath nadimpally
Ranch Hand

Joined: Jan 25, 2005
Posts: 116
Windows box:
This is the endDate Mon Oct 16 15:32:45 CDT 2006
This is todays date Mon Oct 16 15:34:26 CDT 2006

lnux box:
This is the endDate Mon Oct 16 15:32:45 CDT 2006
This is todays date Mon Oct 16 15:25:06 CDT 2006

The system.out.println did it.. Suddenly I realized that the times are different, thanks..
[ October 16, 2006: Message edited by: vishwanath nadimpally ]
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Date.compareTo : misbehaviour on linux environment?
 
Similar Threads
Populating select box with dates
Calculating days between 2 dates.
Date in java
Date Calculations - Difference between 2 dates is off
using init-param to set a value in a table