• Post Reply Bookmark Topic Watch Topic
  • New Topic

Getting different time than system time in Unix (java.util.Date)  RSS feed

 
Venu Gopal
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Following Test program is just working fine on Windows OS but not on Unix.
on Unix this test program is giving 1hr time difference than system time why??
Unix OS command: date
Command to run this Test program: java SysTime1

[ Jess added UBB [code] tags to preserve whitespace, check 'em out! ]
[ April 15, 2004: Message edited by: Jessica Sant ]
 
Vin Kris
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
check the Daylight saving time setting in the unix box. most probably that is your culprit.
 
Paul Sturrock
Bartender
Posts: 10336
Eclipse IDE Hibernate Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The system time is probably set differently on the UNIX machine. Or the machine might have a different Locale. Check what these are first.
BTW: Couple of points - why are you doing this:

when Calendar.getInstance().getTime() gives you the current time?
Also what is the benefit of formatting the date manually? You could perhaps look at java.text.DateFormat which will do this for you.
 
Venu Gopal
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Any idea how to check/set these day light saveing time in unix box?
Basic question: Why JVM picking different time than system time? i think JVM will request OS to give the time and OS should give the same time which we use to get from the command 'date'.
 
Vin Kris
Ranch Hand
Posts: 154
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try this:
System.out.println( java.util.TimeZone.getDefault() );
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!