Need to use unix TZ timezone strings in java Timezone class

Paul Eggert eggert at CS.UCLA.EDU
Mon Jul 12 18:35:50 UTC 2004


"Agarwal, Preeti (Med, GEMS-IT)" <Preeti.Agarwal at med.ge.com> writes:

> java.util.TimeZone tz = java.util.TimeZone.getTimeZone("EST5EDT");
>
> However this sets tz to GMT with 0 offset. How do I get the correct java
> timezone? Soemthing like "America/New_york" that I can use to get the
> current time in that timezone.

I don't know of any Java facility to do that.

My previous message gave you a way of generating a table that maps
strings like "EST5EDT" to strings like "America/New_York", by looking
for "Link" lines in the tz database source files.  You could generate
this table by hand and drop it into your Java source code somewhere.
The idea is that you modify your Java program to look up nonstandard
strings like "EST5EDT" in your own table.  For that particular
example, you'd find an entry in your own table that says
"America/New_York", and then use "America/New_York" instead.



More information about the tz mailing list