Win a copy of Re-engineering Legacy Software this week in the Refactoring forum
or Docker in Action in the Cloud/Virtualization forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Date.compareTo : misbehaviour on linux environment?

 
vishwanath nadimpally
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have this piece of code:



Is Date.compareTo() unreliable?
 
Jim Yingst
Wanderer
Sheriff
Posts: 18671
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[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:
 
vishwanath nadimpally
Ranch Hand
Posts: 116
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic