AW: [opencms-dev] Timezone and DST problems in OpenCms-based system

Jonathan Woods jonathan.woods at scintillance.com
Sat Sep 9 11:28:58 CEST 2006


This shows how little l10n/i18n I've done... please only read on if you're
similarly inexperienced.
 
The answer:
 
1.  Constructing a DateFormat uses the system's timezone by default, and no
timezone is guessed from the Locale used - nor could it be, in general.
 
2.  You can use DateFormat.setTimeZone() to set a specific timezone,
whereupon dates will be formatted accordingly.
 
3.  The so-called timezone rendered by a SimpleDateFormat with the format
string "z" is not in fact the timezone, but a String describing to the time
representation scheme in use given the timezone and (for SimpleDateFormat
with a timezone which uses Daylight Savings Time) the time too.  So for a
SimpleDateFormat whose timezone has been set to "Europe/London" (which is
what I had to use), the timezone part of the formatted String is "BST" for a
summer time and "GMT" for a winter time.  Here "GMT" is the identifier for
the timezone representation scheme, which isn't the same thing as the
identically named timezone.
 
Jon

  _____  

From: opencms-dev-bounces at opencms.org
[mailto:opencms-dev-bounces at opencms.org] On Behalf Of Jonathan Woods
Sent: 09 September 2006 08:15
To: 'The OpenCms mailing list'
Subject: [opencms-dev] Timezone and DST problems in OpenCms-based system


OK, I admit it: this is a slightly off-topic question, but it's about an
issue which I imagine might have affected many OpenCms developers.
 
I'm getting inconstent date formatting results on my UK-based Windows
development box and my US-based Linux/CentOS server running OpenCms.  It
seems that the Linux box is ignoring daylight savings time settings for a
Locale.
 
// Test using instance in time which is largely arbitrary but occurs
// during UK's daylight savings time:
 
SimpleDateFormat sdf = new SimpleDateFormat("HH:mm z", Locale.UK);
sdf.format(new Date(1157782813701));
 
>From the US machine, I get a time in GMT; on the UK machine, I get a time in
BST, which is the GMT daylight savings time zone.  BST is the correct result
for this Date value.  Both machines are using JDK 1.5.0_08, and as it
happens the system clocks on the two machines are roughly the same according
to new Date().getTime().
 
Anyone got any ideas?
 
Jon
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://webmail.opencms.org/pipermail/opencms-dev/attachments/20060909/567506d1/attachment.htm>


More information about the opencms-dev mailing list