Time compatibility issue between Java and C

A

Adi

Hello friend,
Recently I encountered a problem which involve time
synchronication/scheduling between two remote systems. One system
running a Java program has to schedule a task on another system running
a C prog. on TCP interface.
Problem is how to send time/date independent of time-zone and
programming issues. Since systems might have different OS, so epoch
time might cause problem ( I heard UNIX take base value as 1 Jan, 1970
while Win2K takes 1 Jan, 1900).
I just want the value and date-type conformity so as to make message
parsing as simple as possible. So what should be the date-time format
and the data type to use???
Please help in this regard ASAP,
Adi
 
W

Walter Roberson

Recently I encountered a problem which involve time
synchronication/scheduling between two remote systems. One system
running a Java program has to schedule a task on another system running
a C prog. on TCP interface.
Problem is how to send time/date independent of time-zone and
programming issues.

Before that, you have to figure out how to synchronize the times
on the two systems, and -keep- them synchronized.
Since systems might have different OS, so epoch
time might cause problem ( I heard UNIX take base value as 1 Jan, 1970
while Win2K takes 1 Jan, 1900).

I would suggest that you examine how ntp (Network Time Protocol)
handles the issue.
 
N

Nelu

Adi said:
Hello friend,
Recently I encountered a problem which involve time
synchronication/scheduling between two remote systems. One system
running a Java program has to schedule a task on another system running
a C prog. on TCP interface.
Problem is how to send time/date independent of time-zone and
programming issues. Since systems might have different OS, so epoch
time might cause problem ( I heard UNIX take base value as 1 Jan, 1970
while Win2K takes 1 Jan, 1900).
I just want the value and date-type conformity so as to make message
parsing as simple as possible. So what should be the date-time format
and the data type to use???
Please help in this regard ASAP,

You could create the time using mktime then get the time_t value
returned and pass it to gmtime. The struct tm structure you get has
the UTC time in its components. You can do somehting similar in JAVA
using a GregorianCalendar and an instance of TimeZone to convert to
UTC. Now, the components of the GregorianCalendar and struct tm both
show the time for the same time zone, UTC. You can use those values
for synchronization and you can use another TimeZone instance to
switch back to local time or the localtime function in C. You can
avoid using the time_t values this way.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,051
Latest member
CarleyMcCr

Latest Threads

Top