• 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[SOLVED]: WebObjects 5.3.3, DST, NSTimeZone
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re[SOLVED]: WebObjects 5.3.3, DST, NSTimeZone


  • Subject: Re[SOLVED]: WebObjects 5.3.3, DST, NSTimeZone
  • From: Baiss Eric Magnusson <email@hidden>
  • Date: Sat, 10 Mar 2007 20:21:12 -0800

I used the below, it all makes sense, could be I really didn't need all of it.

However, the problem ended up in the loop that created the repetitive events.

Given:
	GregorianCalendar dayForEventGC = new GregorianCalendar();
	dayForEventGC.set( Calendar.YEAR, curYear ); ..etc.

I replaced the line
alteredEvent.setEventDate( new NSTimestamp( dayForEventGC.getTime()));
with
alteredEvent.setEventDate( new NSTimestamp( year, month, day, hour, minute, 0, NSTimeZone.systemTimeZone() ));


On Mar 10, 2007, at 10:12 AM, George Domurot wrote:

I think you'll want something along the lines of:

// determine time zone
//
public NSTimeZone timeZoneObj() {
Number timezone = timeZone(); // get from the client via javascript call to getTimezoneOffset()
if ( timezone == null ) return NSTimeZone.systemTimeZone();
int gmtOffset = timezone.intValue();
return NSTimeZone.timeZoneForSecondsFromGMT( gmtOffset );
} // end timeZoneObj


	// prepare formatter
	//
	NSTimestampFormatter myTimestampFormatter;
	myTimestampFormatter = new NSTimestampFormatter("%I:%M %p");
	myTimestampFormatter.setDefaultFormatTimeZone(timeZone);
	myTimestampFormatter.setDefaultParseTimeZone(timeZone);

Keep your WOString binding for value set to the NSTimestamp, and the only other binding required is formatter to myTimestampFormatter. You can also use this formatter for your WOTextField (not as fancy as your pop-ups) with the same bindings.

On Mar 10, 2007, at 7:34 AM, George Domurot wrote:

Baiss:

If you use a formatter when displaying your time, or within a text field for form entry, you don't have to worry about pushing your Timestamp into the correct zone for display. The formatter will take care of all the adjustments for you. With the formatter you can stick to the data as it's stored and avoid converting it into (or out of) GregorianCalendar.

-George

On Mar 9, 2007, at 10:54 AM, Mark Ritchie wrote:

On 7-Mar-07, at 11:34 AM, Baiss Eric Magnusson wrote:
It seems to me that I need to go back and associate a time zone id for all my events.
and then use this
tz = NSTimestamp.....
NSTimestamp myNSTimestamp = new NSTimestamp(year, month, day, hour, minute, seconds, tz)

Hi Baiss!

Use caution here! As had already been pointed out, NSTimestamp does not store time zone information. I believe that the tz argument in all the constructors is only used to interpret the other arguments.

The docs say this for several of the constructors. The given information is converted and stored as millisecond offset since reference date in the reference timezone. That would be January 1, 1970, 00:00:00 GMT.

As Ken pointed out, you might be better of storing the local time and the time zone so that you can reconstruct the right times. Alternatively, you might find: timestampByAddingGregorianUnits(int years, int months, int days, int hours, int minutes, int seconds) useful. The docs say that it preserves time of day across DST changes.

timestampByAddingGregorianUnits in the docs.

public NSTimestamp timestampByAddingGregorianUnits( int year, int month, int day, int hour, int minute, int second)
Deprecated in the Java Foundation framework. Don't use this method.

Hope that helps! Mark

----
Baiss Eric Magnusson
<http://www.Track-Your-Finances.com>
<http://www.CascadeWebDesign.com>


_______________________________________________ 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: 
 >WebObjects 5.3.3, DST and J2SE 1.4.2 (From: Baiss Eric Magnusson <email@hidden>)
 >Re: WebObjects 5.3.3, DST and J2SE 1.4.2 (From: Pascal Robert <email@hidden>)
 >Re: WebObjects 5.3.3, DST and J2SE 1.4.2 (From: Baiss Eric Magnusson <email@hidden>)
 >Re: WebObjects 5.3.3, DST and J2SE 1.4.2 (From: Ken Anderson <email@hidden>)
 >Re: WebObjects 5.3.3, DST and J2SE 1.4.2 (From: Baiss Eric Magnusson <email@hidden>)
 >Re: WebObjects 5.3.3, DST and J2SE 1.4.2 (From: Chuck Hill <email@hidden>)
 >Re: WebObjects 5.3.3, DST and J2SE 1.4.2 (From: Baiss Eric Magnusson <email@hidden>)
 >Re: WebObjects 5.3.3, DST and J2SE 1.4.2 (From: Mark Ritchie <email@hidden>)
 >Re: WebObjects 5.3.3, DST and J2SE 1.4.2 (From: Baiss Eric Magnusson <email@hidden>)
 >Re: WebObjects 5.3.3, DST and J2SE 1.4.2 (From: George Domurot <email@hidden>)
 >Re: WebObjects 5.3.3, DST and J2SE 1.4.2 (From: Baiss Eric Magnusson <email@hidden>)
 >Re: WebObjects 5.3.3, DST and J2SE 1.4.2 (From: George Domurot <email@hidden>)

  • Prev by Date: locations of DST information
  • Next by Date: Create and Query Multiple Values in an attribute
  • Previous by thread: Re: WebObjects 5.3.3, DST and J2SE 1.4.2
  • Next by thread: Re: WebObjects 5.3.3, DST and J2SE 1.4.2
  • Index(es):
    • Date
    • Thread