Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

System Time

 
pankaj patil
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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?
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Tim Holloway
Saloon Keeper
Pie
Posts: 18094
48
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Peter Johnson
author
Bartender
Posts: 5852
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 4678
7
Linux Mac OS X VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic