• 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: Date-Only NSTimestamps
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Date-Only NSTimestamps


  • Subject: Re: Date-Only NSTimestamps
  • From: David den Boer <email@hidden>
  • Date: Thu, 3 Jan 2008 12:58:35 -0800

Adding to this whole discussion...
I work on a rather large scheduling app that has to work globally. We store all time in GMT and then convert it on the fly depending on the timezone and locale of the user accessing the app.
For this, we use a few different java DateFormat's depending on what type of time we need to present either in the Session or in a ThreadLocal depending on the app being used (there are many different apps).
We also have a few methods to do start of day and end of day as well.



The key for us is using GregorianCalendar for everything -- as soon as we need to do any sort of date math, we make a GregorianCalendar object out of the timestamp. Conversion between GMT and a local timezone is simple too :

/**
* 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);
}

If anyone needs more info on how we use time and timezones, please contact me.

Thanks,
David.

On Jan 3, 2008, at 11:50 AM, Andrew Lindesay wrote:

Hello;

I jotted-up some notes about how I handle dates, timestamps and timezones that might be of interest in the context of this thread and mirrors Pierre's comment below.  See section 0.5.21 in the following document;

http://homepage.mac.com/andrewlindesay/tmp/LEWOStuffOverview.pdf

cheers.

Because of this, storing any date in local time instead of GMT is likely to leads to disappointment. There is no guarantee that the time zone you used to store your date will be the same than the one you used to retrieve it. I fact there is a good possibility that this will have changed under your feet. Typically each revision of the JVM includes a new version of the time zone database. The only safe way of storing dates is GMT as this is by definition guaranteed not to change.


 _______________________________________________
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

References: 
 >Date-Only NSTimestamps (From: David Avendasora <email@hidden>)
 >Re: Date-Only NSTimestamps (From: Chuck Hill <email@hidden>)
 >Re: Date-Only NSTimestamps (From: Simon McLean <email@hidden>)
 >Re: Date-Only NSTimestamps (From: Chuck Hill <email@hidden>)
 >Re: Date-Only NSTimestamps (From: Simon McLean <email@hidden>)
 >Re: Date-Only NSTimestamps (From: Andrew Lindesay <email@hidden>)
 >Re: Date-Only NSTimestamps (From: Chuck Hill <email@hidden>)
 >Re: Date-Only NSTimestamps (From: Simon McLean <email@hidden>)
 >Re: Date-Only NSTimestamps (From: "Mr. Pierre Frisch" <email@hidden>)
 >Re: Date-Only NSTimestamps (From: Andrew Lindesay <email@hidden>)

  • Prev by Date: Re: Class 'Session' exists but is not a subclass of WOSession?
  • Next by Date: Re: Any tutorials on using direct actions and/or component actions with AJAX
  • Previous by thread: Re: Date-Only NSTimestamps
  • Next by thread: Re: Date-Only NSTimestamps
  • Index(es):
    • Date
    • Thread