Re: Diagnose why Pacific TZ has wrong start/stop dates for DST, with
JDK 1.6 on Ubuntu
On Apr 14, 7:55 pm, "John B. Matthews" <nos...@nospam.invalid> wrote:
In article
<57d025bf-2036-4835-b80e-5b948dff9...@d25g2000prn.googlegroups.com>,
David Karr <davidmichaelk...@gmail.com> wrote:
On Apr 14, 3:18 pm, "John B. Matthews" <nos...@nospam.invalid> wrote:
In article
<3acf3c31-e7c6-40ff-8127-a40b8debe...@y10g2000prc.googlegroups.com>,
"david.karr" <davidmichaelk...@gmail.com> wrote:
Here in Seattle, on April 14, we're in daylight savings time.
I've noticed since DST started that log files created by Java
applications on my Ubuntu box are an hour behind. I figured it
had something to do with daylight savings time. Non-Java
applications do not display this symptom.
If it matters, here's the output of "java -version":
java version "1.6.0_10" Java(TM) SE Runtime Environment (build
1.6.0_10-b33) Java HotSpot(TM) Client VM (build 11.0-b15, mixed
mode, sharing)
I wrote a small test application that prints out relevant
information about daylight savings time. I'll attach the test
code, but the output it produces follows this. You'll see that as
of today, it thinks DST is not in effect. It also shows that it
thinks DST starts on April 26, and ends on October 25, which is
not correct.
[...]
You don't mention which version of Ubuntu, but apt-get may have
updated your tzdata, already. You'll need to update your Sun
tables, too.
<http://java.sun.com/javase/tzupdater_README.html>
I'm using Ubuntu 8.10.
Good, you can get updates. Be sure your tzdata is current. It looks like
tzdata 2009d-0ubuntu0.8.10 was accepted 30-Mar-2009.
Your information was promising, but it didn't appear to fix the
problem.
I installed the tzupdater tool, and then from the command line, I
first reran my test app to make sure it's reporting the same results
as it did before. Then, I ran the tzupdater with "-t". This showe=
d
lots of output indicating various test failures and "time zone not
found" lines. Then, I ran it with "-u" and it chugged for a second
and went back to the prompt. I then reran my test app, and the
results didn't change. I then reran the tzupdater with "-t", and it
produced no output. This tells me that the update did something, but
not quite what I need.
I assume the timezone data is only relevant at runtime, so I
shouldn't have to recompile the class in my test app?
I wouldn't think so, but your attached code wasn't propagated.
That's because I didn't attach it.
I'll add two blocks here, one with the code for the class, and one
showing the current output I get.
------------------------------
package timedate;
import java.text.DateFormat;
import java.util.Calendar;
import java.util.Date;
import java.util.TimeZone;
import
com.sun.org.apache.xerces.internal.impl.xpath.regex.ParseException;
public class TimeDate
{
public static void main(String[] args)
{
TimeZone timezone = TimeZone.getDefault();
Date date = new Date();
System.out.println("date[" + date +
"] zonename[" + timezone.getDisplayName() +
"] dstSavings[" + timezone.getDSTSavings()
+
"] usesDST[" + timezone.useDaylightTime() +
"] inDST[" + timezone.inDaylightTime(date)
+
"] rawOffset[" + timezone.getRawOffset() +
"] offset[" + timezone.getOffset
(date.getTime()) + "]");
Calendar calendar = Calendar.getInstance();
for (int ctr = 0; ctr < 12; ++ ctr)
{
testDateForDST(calendar.getTime());
calendar.add(Calendar.MONTH, 1);
}
testDateStrForDST("April 26, 2009");
testDateStrForDST("April 27, 2009");
testDateStrForDST("October 25, 2009");
testDateStrForDST("October 26, 2009");
}
public static void testDateForDST(Date date)
{
System.out.println("date[" + date +
"] inDST[" + inDST(Calendar.getInstance().getTimeZone
(), date) + "]");
}
public static void testDateStrForDST(String str)
{
DateFormat dateFormat = DateFormat.getDateInstance();
try
{
Date date = dateFormat.parse(str);
testDateForDST(date);
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
public static boolean inDST(TimeZone timeZone, Date date)
{
return Calendar.getInstance().getTimeZone().inDaylightTime
(date);
}
}
------------------------------
------------------------------
date[Mon Apr 13 13:04:01 PST 2009] zonename[Pacific Standard Time]
dstSavings[3600000] usesDST[true] inDST[false] rawOffset[-28800000]
offset[-28800000]
date[Mon Apr 13 13:04:01 PST 2009] inDST[false]
date[Wed May 13 13:04:01 PDT 2009] inDST[true]
date[Sat Jun 13 13:04:01 PDT 2009] inDST[true]
date[Mon Jul 13 13:04:01 PDT 2009] inDST[true]
date[Thu Aug 13 13:04:01 PDT 2009] inDST[true]
date[Sun Sep 13 13:04:01 PDT 2009] inDST[true]
date[Tue Oct 13 13:04:01 PDT 2009] inDST[true]
date[Fri Nov 13 13:04:01 PST 2009] inDST[false]
date[Sun Dec 13 13:04:01 PST 2009] inDST[false]
date[Wed Jan 13 13:04:01 PST 2010] inDST[false]
date[Sat Feb 13 13:04:01 PST 2010] inDST[false]
date[Sat Mar 13 13:04:01 PST 2010] inDST[false]
date[Sun Apr 26 00:00:00 PST 2009] inDST[false]
date[Mon Apr 27 00:00:00 PDT 2009] inDST[true]
date[Sun Oct 25 00:00:00 PDT 2009] inDST[true]
date[Mon Oct 26 00:00:00 PST 2009] inDST[false]
---------------------------------