Time compatibility issue between Java and C

Discussion in 'C Programming' started by Adi, Jun 30, 2006.

  1. Adi

    Adi Guest

    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
    Adi, Jun 30, 2006
    #1
    1. Advertising

  2. In article <>,
    Adi <> 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
    Walter Roberson, Jun 30, 2006
    #2
    1. Advertising

  3. Adi

    Nelu Guest

    "Adi" <> 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...)
    Nelu, Jun 30, 2006
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Maria
    Replies:
    1
    Views:
    346
    Joona I Palaste
    Dec 17, 2004
  2. Prashant

    C and C++ compatibility issue

    Prashant, Jul 20, 2004, in forum: C++
    Replies:
    7
    Views:
    569
    Prashant
    Jul 26, 2004
  3. bucket79
    Replies:
    1
    Views:
    744
    Arne Koewing
    Aug 21, 2003
  4. Mike Kent
    Replies:
    2
    Views:
    325
    Mike Kent
    Dec 30, 2003
  5. flamesrock
    Replies:
    8
    Views:
    452
    Hendrik van Rooyen
    Nov 24, 2006
Loading...

Share This Page