What you have there is fully DST compatible, if you do not use NSTimestamp :-)
That being said, if you avoid using timezones with NSTimestamp, and do not use the time-component constructor :
then you are good. If you need that one, then try :
/** * Creates a new NSTimestamp using the passed in components and timezone info. */ public static NSTimestamp timestampForComponents(int iYear, int iMonth, int iDay, int iHours, int iMinutes, int iSeconds, TimeZone iZone) { GregorianCalendar aCal = new GregorianCalendar(iYear, iMonth, iDay, iHours, iMinutes, iSeconds); if (iZone != null) aCal.setTimeZone(iZone); return new NSTimestamp(aCal.getTime()); }
OR to change timezone on an existing date :
/** * Returns a new time stamp for the passed in Timezone. * * @param iMillis time stamp to be converted * @param iZone Timzone in which conversion is needed. * @return an NSTimestamp with date converted to iZone. */ public static NSTimestamp changeDateForTimezone(long iMillis, TimeZone iZone) { long anOffset = 0l; if (iZone != null) anOffset = iZone.getOffset(iMillis); return new NSTimestamp(iMillis + anOffset); } public static NSTimestamp changeDateForTimezone(NSTimestamp iTimestamp, TimeZone iZone) { return changeDateForTimezone(iTimestamp.getTime(), iZone); }
On Jan 26, 2007, at 2:45 PM, Ken Anderson wrote: Is there a reasonable solution for this yet? I'm running java 1.5.0_06, which sun claims is compatible with the new daylight saving time change, but it is not. How can I get this fixed? I'm on OS X 10.4.8.
Ken
|