Re: NSNumberFormatter & NSTimestamp -- Not Happening
Re: NSNumberFormatter & NSTimestamp -- Not Happening
- Subject: Re: NSNumberFormatter & NSTimestamp -- Not Happening
- From: Art Isbell <email@hidden>
- Date: Wed, 17 Sep 2003 20:45:34 -1000
On Tuesday, September 16, 2003, at 09:19 PM, Denis Stanton wrote:
Thank you for taking the time to look into this.
On Wednesday, September 17, 2003, at 04:52 PM, Albert Jagnow wrote:
I am pretty sure that NSTimestamp is stored in UTC which is not
affected by daylight savings time. If you compare two timestamps
where one was stored on October 25 2003 at 2:00AM local time and the
other was stored on October 26 2003 at 1:00AM local time after the
time change, these dates are 24 hours apart even though one is at 2:00
local time and the other is at 1:00 local time. If you look at the
UTC time for each in a database (assuming local time is central time)
you should see something like 2003-10-25 07:00:00 for the first time
and 2003-10-26 07:00:00 for the second. The difference calculation
below should give you a diff of 24 hours or 1 day. This is the
correct difference is it not?
I'm pretty certain Albert is correct. JDBC (or at least the version
used by WO) doesn't support a timestamp with time zone data type, so
the timestamp stored in a DB has no time zone info with it. JDBC
delivers time in UTC to the DB server from the WO app. So the
difference between any two timestamp values stored in a DB should be
unaffected by daylight savings time changes.
NSTimeZone timeZone = NSTimeZone.systemTimeZone();
outDate = new NSTimestamp(dateYear, dateMonth, dateDay, 0, 0,
0, timeZone);
I think specifying a time zone here may be causing unnecessary
complication. Why not just use timestamps in UTC for everything except
where local times need to be displayed? You can make that adjustment
just for display purposes.
Maybe the better answer is to set a timezone of UTC in the first place,
but I haven't figured out how to do this so I'm using system time.
Have you tried this?
outDate = new NSTimestamp(dateYear, dateMonth, dateDay, 0, 0, 0, null);
Having said all that, dealing with dates and times in WO got much more
difficult after the move from ObjC to Java. The Java date and time
classes are a real mess because the first attempt was botched badly.
But because of existing code, the original classes, many methods of
which are deprecated, live on while another set of classes attempts to
model date and time better. So take my recommendations with the
confused grain of salt that I know exists. I usually have to write
some simple test cases to figure out how to program dates and times in
Java.
Aloha,
Art
_______________________________________________
webobjects-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/webobjects-dev
Do not post admin requests to the list. They will be ignored.