Just filed as bug 6494932:

rawOffset of NSTimeZone is not set correctly. E.g. it reports zero for Europe/Berlin while it should be one hour. When using java.util.TimeZone instead of NSTimeZone, everything is OK.

This happens with both WO 5.3.3 and 5.4.3.

--- Reproduction code ---

package timo.tests;

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

import com.webobjects.foundation.NSTimeZone;
import com.webobjects.foundation.NSTimestamp;

public class Timezones {

        public static void main(String[] args) {
                test(TimeZone.getTimeZone("Europe/Berlin"));
                test(NSTimeZone.timeZoneWithName("Europe/Berlin", false));
        }

        private static void test(TimeZone timeZone) {
System.out.println("Testing with " + timeZone.getClass() + " (" + timeZone + ")\n"); System.out.println("timeZone.getRawOffset() = " + timeZone.getRawOffset()+"\n");
                
                Calendar calendar = new GregorianCalendar(timeZone);
                Date trialTime = new NSTimestamp(2008, 5, 1, 0, 0, 0, timeZone);
                System.out.println(trialTime);
                calendar.setTime(trialTime);

                System.out.println("YEAR: " + calendar.get(Calendar.YEAR));
                System.out.println("MONTH+1: " + (calendar.get(Calendar.MONTH) 
+ 1));
System.out.println("DAY_OF_MONTH: " + calendar.get (Calendar.DAY_OF_MONTH));
                System.out.println();
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();
System.out.println("ZONE_OFFSET: " + calendar.get (Calendar.ZONE_OFFSET)); System.out.println("DST_OFFSET: " + calendar.get (Calendar.DST_OFFSET));
                System.out.println("---");
        }

}


--- Output ---
Testing with class sun.util.calendar.ZoneInfo (sun.util.calendar.ZoneInfo[id="Europe/ Berlin",offset=3600000,dstSavings=3600000,useDaylight=true,transitions=1 43,lastRule=java.util.SimpleTimeZone[id=Europe/ Berlin,offset=3600000,dstSavings=3600000,useDaylight=true,startYear=0,st artMode=2,startMonth=2,startDay=-1,startDayOfWeek=1,startTime=3600000,st artTimeMode=2,endMode=2,endMonth=9,endDay=-1,endDayOfWeek=1,endTime=3600 000,endTimeMode=2]])

timeZone.getRawOffset() = 3600000

2008-04-30 22:00:00 Etc/GMT
YEAR: 2008
MONTH+1: 5
DAY_OF_MONTH: 1

HOUR_OF_DAY: 0
MINUTE: 0
SECOND: 0

ZONE_OFFSET: 3600000
DST_OFFSET: 3600000
---
Testing with class com.webobjects.foundation.NSTimeZone (Europe/ Berlin (CET) offset 3600)

timeZone.getRawOffset() = 0

2008-04-30 22:00:00 Etc/GMT
YEAR: 2008
MONTH+1: 4
DAY_OF_MONTH: 30

HOUR_OF_DAY: 23
MINUTE: 0
SECOND: 0

ZONE_OFFSET: 0
DST_OFFSET: 3600000
---

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to