Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / February 2006

Tip: Looking for answers? Try searching our database.

Java time zones

Thread view: 
N. Dose - 27 Jan 2006 11:34 GMT
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++.
Robert Klemme - 27 Jan 2006 11:53 GMT
> Does anyone know where the JRE gets its time zone info from? In the
> Sun JDK
[quoted text clipped - 8 lines]
> 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
Thomas Weidenfeller - 27 Jan 2006 12:18 GMT
> 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
Signature

The comp.lang.java.gui FAQ:
ftp://ftp.cs.uu.nl/pub/NEWS.ANSWERS/computer-lang/java/gui/faq
http://www.uni-giessen.de/faq/archiv/computer-lang.java.gui.faq/

P.Hill - 01 Feb 2006 04:26 GMT
>> 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


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2009 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.