B
Big Jim
Hi Guys, I'm having problems detecting DST. On a solaris box in the UK
(and on my windows 2000 PC) I have the following test prog:
import java.util.*;
public class DateTest
{
public static void main(String args[])
{
printDate(new java.util.Date(1163203200282L), "Nov 11?");
printDate(new java.util.Date(1152230400386L), "Jul 7th?");
}
static void printDate(java.util.Date date, String desc)
{
GregorianCalendar c = new GregorianCalendar(
date.getYear(), date.getMonth(), date.getDate());
System.out.println("*******************************");
System.out.println(desc);
System.out.println("Date : " + date);
System.out.println("Long : " + date.getTime());
System.out.println("Zone Offset : " +
c.get(Calendar.ZONE_OFFSET));
System.out.println("DST Offset : " +
c.get(Calendar.DST_OFFSET));
System.out.println("Long Corrected : " + (
date.getTime() + c.get(Calendar.ZONE_OFFSET) +
c.get(Calendar.DST_OFFSET)));
System.out.println("Date Corrected : " + new Date(
date.getTime() - (c.get(Calendar.ZONE_OFFSET) +
c.get(Calendar.DST_OFFSET))));
System.out.println("*******************************");
}
}
which produces the following output:
*******************************
Nov 11?
Date : Sat Nov 11 00:00:00 GMT 2006
Long : 1163203200282
Zone Offset : 0
DST Offset : 0
Long Corrected : 1163203200282
Date Corrected : Sat Nov 11 00:00:00 GMT 2006
*******************************
*******************************
Jul 7th?
Date : Fri Jul 07 01:00:00 BST 2006
Long : 1152230400386
Zone Offset : 0
DST Offset : 0
Long Corrected : 1152230400386
Date Corrected : Fri Jul 07 01:00:00 BST 2006
*******************************
Why am I not getting a DST offset for July 7th when it seems to know
it's a BST date?
Cheers, Richard.
(and on my windows 2000 PC) I have the following test prog:
import java.util.*;
public class DateTest
{
public static void main(String args[])
{
printDate(new java.util.Date(1163203200282L), "Nov 11?");
printDate(new java.util.Date(1152230400386L), "Jul 7th?");
}
static void printDate(java.util.Date date, String desc)
{
GregorianCalendar c = new GregorianCalendar(
date.getYear(), date.getMonth(), date.getDate());
System.out.println("*******************************");
System.out.println(desc);
System.out.println("Date : " + date);
System.out.println("Long : " + date.getTime());
System.out.println("Zone Offset : " +
c.get(Calendar.ZONE_OFFSET));
System.out.println("DST Offset : " +
c.get(Calendar.DST_OFFSET));
System.out.println("Long Corrected : " + (
date.getTime() + c.get(Calendar.ZONE_OFFSET) +
c.get(Calendar.DST_OFFSET)));
System.out.println("Date Corrected : " + new Date(
date.getTime() - (c.get(Calendar.ZONE_OFFSET) +
c.get(Calendar.DST_OFFSET))));
System.out.println("*******************************");
}
}
which produces the following output:
*******************************
Nov 11?
Date : Sat Nov 11 00:00:00 GMT 2006
Long : 1163203200282
Zone Offset : 0
DST Offset : 0
Long Corrected : 1163203200282
Date Corrected : Sat Nov 11 00:00:00 GMT 2006
*******************************
*******************************
Jul 7th?
Date : Fri Jul 07 01:00:00 BST 2006
Long : 1152230400386
Zone Offset : 0
DST Offset : 0
Long Corrected : 1152230400386
Date Corrected : Fri Jul 07 01:00:00 BST 2006
*******************************
Why am I not getting a DST offset for July 7th when it seems to know
it's a BST date?
Cheers, Richard.