By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
446,332 Members | 1,414 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 446,332 IT Pros & Developers. It's quick & easy.

Time compatibility issue between Java and C

P: n/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

Jun 30 '06 #1
Share this Question
Share on Google+
2 Replies


P: n/a
In article <11**********************@b68g2000cwa.googlegroups .com>,
Adi <ad******@gmail.com> wrote:
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.
--
"It is important to remember that when it comes to law, computers
never make copies, only human beings make copies. Computers are given
commands, not permission. Only people can be given permission."
-- Brad Templeton
Jun 30 '06 #2

P: n/a
"Adi" <ad******@gmail.com> writes:
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.
--
Ioan - Ciprian Tandau
tandau _at_ freeshell _dot_ org (hope it's not too late)
(... and that it still works...)
Jun 30 '06 #3

This discussion thread is closed

Replies have been disabled for this discussion.