• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

System Time

 
Ranch Hand
Posts: 98
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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?
 
author
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Saloon Keeper
Posts: 27882
197
Android Eclipse IDE Tomcat Server Redhat Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
Posts: 5856
7
Android Eclipse IDE Ubuntu
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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...
 
Rancher
Posts: 4804
7
Mac OS X VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic