Java time zones

N

N. Dose

Does anyone know where the JRE gets its time zone info from? In the Sun JDK
1.4, there is a folder jre/lib/zi. Is this the public-domain tz database? If
so is there a way to find out what version of the db it is? Or a way to
access it? How does the JRE use these files?

The issue at hand is the following: we read time info from an Oracle
database via JDBC and via C++ - we need the datetime information to match up
exactly in both environments. Unfortunately we don't rely on Oracle to
handle/interpret our datetimes - this is all done via JDBC. So I need to
understand how JDBC interprets dates so that I can mimic this behavior in
C++.
 
R

Robert Klemme

N. Dose said:
Does anyone know where the JRE gets its time zone info from? In the
Sun JDK
1.4, there is a folder jre/lib/zi. Is this the public-domain tz
database? If so is there a way to find out what version of the db it
is? Or a way to access it? How does the JRE use these files?

The issue at hand is the following: we read time info from an Oracle
database via JDBC and via C++ - we need the datetime information to
match up exactly in both environments. Unfortunately we don't rely on
Oracle to handle/interpret our datetimes - this is all done via JDBC.
So I need to understand how JDBC interprets dates so that I can mimic
this behavior in C++.

We went through this recently also. Use Oracle 9/10 with TIMESTAMP and
TIMESTAMP WITH LOCAL TIMEZONE. The final solution was that our
application initially tests the set of Java time zone ids against Oracle
and created a list of those that yield same (or at least similar) results.
There are still some differences on the days where DST changes but we
decided to live with that. HTH

Kind regards

robert
 
T

Thomas Weidenfeller

N. Dose said:
Does anyone know where the JRE gets its time zone info from? In the Sun JDK
1.4, there is a folder jre/lib/zi. Is this the public-domain tz database?

As fare as I know, yes, But Sun encoded it differently than the normal
Unix zoneinfo file format :-( Don't ask me why. And don't ask me why
they just didn't use the existing database when on Unix, and only
provide an own when on Systems which don't have one.
If
so is there a way to find out what version of the db it is? Or a way to
access it?

There are AFAIK no public available tools for accessing the files
directly. It should probably be possible to hack the file format, by
comparing a file with Suns encoding with a matching file with the normal
Unix encoding
How does the JRE use these files?

Last time I looked they loaded them with proprietary, undocumented
classes, and they used a proprietary subclass of the public abstract
TimeZone class to provide the information for applications.

The issue at hand is the following: we read time info from an Oracle
database via JDBC and via C++ - we need the datetime information to match up
exactly in both environments. Unfortunately we don't rely on Oracle to
handle/interpret our datetimes - this is all done via JDBC. So I need to
understand how JDBC interprets dates so that I can mimic this behavior in
C++.

If you store the time information as timestamps (e.g. the typical number
of (milli)seconds since 1970-01-01 00:00 UTC), you would at least know
that Java and C++ start from the same value. The rest would then "just"
be a representation issue. Comparisons, calculation of differences of
the timestamp values, etc. should work the same on both platforms in
that case. If you, however, put local formated time information in the
DB, then ugh ...

/Thomas
 
P

P.Hill

Thomas said:
N. Dose said:
Does anyone know where the JRE gets its time zone info from? In the
Sun JDK
1.4, there is a folder jre/lib/zi. Is this the public-domain tz database?
[...]

There are AFAIK no public available tools for accessing the [Sun] files
directly. It should probably be possible to hack the file format, by
comparing a file with Suns encoding with a matching file with the normal
Unix encoding.

To go the other way and create a timezone object from the Olsen database
consider a set Java class which can parse the source and produce
timezones.

http://joda-time.sourceforge.net/api-release/org/joda/time/tz/ZoneInfoCompiler.html

With the last step to convert a Joda timezone to java.util.Timezone, if
that is really needed.

Note that keeping your Java code up to date is no small task,
the tz data changes more often than once a month.

-Paul
 

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,981
Messages
2,570,188
Members
46,733
Latest member
LonaMonzon

Latest Threads

Top