This week's book giveaway is in the Java 8 forum.
We're giving away four copies of Java 8 in Action and have Raoul-Gabriel Urma, Mario Fusco, and Alan Mycroft on-line!
See this thread for details.
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 Java 8 in Action this week in the Java 8 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 ]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Date.compareTo : misbehaviour on linux environment?
 
Similar Threads
Calculating days between 2 dates.
Date Calculations - Difference between 2 dates is off
Date in java
using init-param to set a value in a table
Populating select box with dates