my dog learned polymorphism
The moose likes Linux / UNIX and the fly likes System Time Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of OCA Java SE 8 Programmer I Study Guide this week in the OCAJP 8 forum!
JavaRanch » Java Forums » Engineering » Linux / UNIX
Bookmark "System Time " Watch "System Time " New topic
Author

System Time

pankaj patil
Ranch Hand

Joined: Dec 19, 2004
Posts: 98
i have 2 code
1) Java
2) Pro* c

i have one operation where in my java code pushes some data through socket to the Proc c code.
in the data i capture the time when i am sending the data and the proc code also print the time when it has received the packet from the socket .
but i observed that the time printed in the java code is more the time printed in the proc code .

My java & proc code are in the same unix machine.

Is this behavior of the unix machine?


Regards,
Pankaj Patil
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5852
    
    7

Your JVM is probably picking up the wrong time zone. You can specify your timezone on java command by using -Duser.timezone="xxxx/yyyyy".

This mismatch of time zones seems to be fairly prevalent on Linux machines - I have seen dozens of forum posts on this same topic.

JBoss In Action
Tim Holloway
Saloon Keeper

Joined: Jun 25, 2001
Posts: 17149
    
  27

Peter Johnson wrote:
This mismatch of time zones seems to be fairly prevalent on Linux machines - I have seen dozens of forum posts on this same topic.


I recommend setting the hardware clock to UTC. Especially on servers, but even on desktop systems, since Linux tends not to handle Daylight Savings as well using a local-time hardware clock. That should help a lot. Of course, you still need to keep an eye on the Unix user and JVM locale settings.


An IDE is no substitute for an Intelligent Developer.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5852
    
    7

I recommend setting the hardware clock to UTC.

That seems to cause problems when dual booting Linux and Windows - Windows tends to reset the hardware clock to local time, if I recall correctly when i tried this before. But then it has been a while...

Actually, thinking it over, Windows probably sets the clock to the "home time zone" time and lets you set a second time zone (which I have used while traveling). Perhaps if I set Windows "home time zone" to UTC and then set an "away time zone" to local time. Hmm, something to try...
Pat Farrell
Rancher

Joined: Aug 11, 2007
Posts: 4659
    
    5

Peter Johnson wrote:That seems to cause problems when dual booting Linux and Windows

Then the answer is clear: stay in Linux :-)

I always run my servers at UTC. It tends to make things a lot more consistent. We just treat it as the time, and then apply whatever local time makes sense.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: System Time
 
It's not a secret anymore!