Re: DST Start date
In article <4ac7cb44$0$290$14726298@news.sunsite.dk>,
Arne Vajh??j <arne@vajhoej.dk> wrote:
Roedy Green wrote:
Is there a simpler way to find out when DST starts in a given year
than stepping through the year day by day calling
TimeZone.inDaylightTime( Date )?
No, that information is private in the SimpleTimeZone class.
This is correct, but one can examine the values in the private
simpleTimeZoneParams array of sun.util.calendar.ZoneInfo. The number and
meaning of the parameters are a function of which SimpleTimeZone
constructor was used to create the ZoneInfo, as described here:
<http://www.docjar.com/html/api/sun/util/calendar/ZoneInfo.java.html>
<method>
private static void printTzParams (String id) {
TimeZone tz = TimeZone.getTimeZone(id);
String name = "simpleTimeZoneParams";
final Field fields[] = tz.getClass().getDeclaredFields();
for (int i = 0; i < fields.length; i++) {
if (name.equals(fields[i].getName())) {
try {
fields[i].setAccessible(true);
int[] ia = (int[]) fields[i].get(tz);
System.out.print("Params for "
+ tz.getID() + ": ");
for (int j = 0; j < ia.length; j++) {
System.out.print(ia[j] + " ");
}
System.out.println();
}
catch (IllegalAccessException e) {
System.err.println("IllegalAccess: " + name);
}
}
}
}
</method>
<example>
Params for Europe/London: 2 -1 1 3600000 2 9 -1 1 3600000 2
Params for Europe/Zurich: 2 -1 1 3600000 2 9 -1 1 3600000 2
Params for US/Eastern: 2 8 -1 7200000 10 1 -1 7200000
Params for US/Pacific: 2 8 -1 7200000 10 1 -1 7200000
</example>
--
John B. Matthews
trashgod at gmail dot com
<http://sites.google.com/site/drjohnbmatthews>