File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
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
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: 5827
    
    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: 16055
    
  21

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.


Customer surveys are for companies who didn't pay proper attention to begin with.
Peter Johnson
author
Bartender

Joined: May 14, 2008
Posts: 5827
    
    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: 4655
    
    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