• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSTimestamp problem
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTimestamp problem


  • Subject: Re: NSTimestamp problem
  • From: Chuck Hill <email@hidden>
  • Date: Mon, 18 Dec 2006 19:05:04 -0800

On Dec 18, 2006, at 6:45 PM, Jerry W. Walker wrote:

Hi, Dan,

You're dealing with a Daylight Savings Time problem.

Yes, the notorious One Hour Shift.


I haven't tried to keep up with Java's calendar routines over the last few months, but if you go to the page on the US Naval Observatory web site that describes clock changes at:

   http://aa.usno.navy.mil/faq/docs/daylight_time.html

...the first paragraph says:

     Currently, daylight time begins in the United States
     on the first Sunday in April and ends on the last
     Sunday in October. On the first Sunday in April,
     clocks are set ahead one hour at 2:00 a.m. local
     standard time, which becomes 3:00 a.m. local
     daylight time. On the last Sunday in October, clocks
     are set back one hour at 2:00 a.m. local daylight
     time, which becomes 1:00 a.m. local standard time.
     These dates were recently modified with the
     passage of the Energy Policy Act of 2005, Pub. L.
     no. 109-58, 119 Stat 594 (2005). Starting in
     March 2007, daylight time in the United States
     will begin on the second Sunday in March and end
     on the first Sunday in November.

...and therein lies your problem.

As for a workaround, I'm not sure what to suggest. However, I thought that the later JVMs had adapted to the change in law.

I think that is exactly the problem. We are not in DST now, but late March will be. Java is very "accurate" WRT time and does not handle it as we would in day to day life. 9AM March 21 is not exactly N x 24 hours away, it is N x 24 +/- 1 depending on which way you are crossing the DST boundary. If you have dates at midnight, even the date will change! Much fin ensues. If you don't need the time, setting it to noon will avoid the date shift. That is of no use to you. You can use different formatters (with the time zone set differently) for dates in and out of DST. You could also store the date (at noon) in one field and the in another.


Java.  Dates.  If there is a hell on earth for developers, it is this.


Chuck

On Dec 18, 2006, at 8:31 PM, Dan Faber wrote:

Hi everyone:

I have just run into an apparent NSTimestamp problem. I have a scheduling program, and it has been working well. Recently we tried to schedule an appt for March, and the NSTimestamp is giving us back a time that is one hour earlier than the time that is designated. This occurs between March 11 and March 31, 2007, a 3 week period. The problem does not seem to occur for dates before that period or afterwards. It does not appear to be an NSTimestampFormatter problem, as it exists with or without using the formatter.

The time is correct in the database after a save, but it immediately gets displayed an hour early. The problem occurs with two different versions of the mysql-connector (including the most recent). It occurs on two different machines, both running OSX version 10.4.8.

Converting the date to java.util.GregorianCalendar appears to produce the correct result for java.util.GregorianCalendar.HOUR_OF_DAY.

So far I have not seen anything on the list about this. Anyone have any ideas what's up?

Dan Faber
_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40gmail.com


This email sent to email@hidden


--
__ Jerry W. Walker,
WebObjects Developer/Instructor for High Performance Industrial Strength Internet Enabled Systems


    email@hidden
    203 278-4085        office



_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
40global-village.net


This email sent to email@hidden


--

Practical WebObjects - for developers who want to increase their overall knowledge of WebObjects or who are trying to solve specific problems.
http://www.global-village.net/products/practical_webobjects






_______________________________________________
Do not post admin requests to the list. They will be ignored.
Webobjects-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: NSTimestamp problem
      • From: Ken Anderson <email@hidden>
References: 
 >NSTimestamp problem (From: Dan Faber <email@hidden>)
 >Re: NSTimestamp problem (From: "Jerry W. Walker" <email@hidden>)

  • Prev by Date: Re: NSTimestamp problem
  • Next by Date: Re: NSTimestamp problem
  • Previous by thread: Re: NSTimestamp problem
  • Next by thread: Re: NSTimestamp problem
  • Index(es):
    • Date
    • Thread