Comment 0 for bug 49068

Revision history for this message
Allen Crider (acrider77) wrote : Date() commands problem with DST

Binary package hint: sun-java5-bin

The following source code (provided to me by a developer on the FreeGuide-TV project) demonstrates the problem:

import java.util.Calendar;
import java.util.Date;
import java.util.GregorianCalendar;

public class TimeTester
{

    public static void main( String[] args )
    {
        System.out.println("Current Time");
        Calendar calendar = new GregorianCalendar();
        Date trialTime = new Date();
        calendar.setTime(trialTime);

        // print out a bunch of interesting things
        System.out.println("ERA: " + calendar.get(Calendar.ERA));
        System.out.println("YEAR: " + calendar.get(Calendar.YEAR));
        System.out.println("MONTH: " + calendar.get(Calendar.MONTH));
        System.out.println("WEEK_OF_YEAR: " +
calendar.get(Calendar.WEEK_OF_YEAR));
        System.out.println("WEEK_OF_MONTH: " +
calendar.get(Calendar.WEEK_OF_MONTH));
        System.out.println("DATE: " + calendar.get(Calendar.DATE));
        System.out.println("DAY_OF_MONTH: " +
calendar.get(Calendar.DAY_OF_MONTH));
        System.out.println("DAY_OF_YEAR: " +
calendar.get(Calendar.DAY_OF_YEAR));
        System.out.println("DAY_OF_WEEK: " +
calendar.get(Calendar.DAY_OF_WEEK));
        System.out.println("DAY_OF_WEEK_IN_MONTH: "
                           + calendar.get(Calendar.DAY_OF_WEEK_IN_MONTH));
        System.out.println("AM_PM: " + calendar.get(Calendar.AM_PM));
        System.out.println("HOUR: " + calendar.get(Calendar.HOUR));
        System.out.println("HOUR_OF_DAY: " +
calendar.get(Calendar.HOUR_OF_DAY));
        System.out.println("MINUTE: " + calendar.get(Calendar.MINUTE));
        System.out.println("SECOND: " + calendar.get(Calendar.SECOND));
        System.out.println("MILLISECOND: " +
calendar.get(Calendar.MILLISECOND));
        System.out.println("ZONE_OFFSET: "
                           +
(calendar.get(Calendar.ZONE_OFFSET)/(60*60*1000)));
        System.out.println("DST_OFFSET: "
                           +
(calendar.get(Calendar.DST_OFFSET)/(60*60*1000)));
    }

}

When run using Sun Java, the DST_OFFSET is 0, even though my time zone is currently at Central Daylight Time. I also tried alternatives to Sun Java. Blackdown Java has the same problem, but GNU Java and Kaffe produce the correct results. Unfortunately, Sun Java is the only package that has been able to run FreeGuide-TV for me so far, which is what I was using when I discovered this bug.