• 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: NSTimestampFormatter and the GMT offset
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSTimestampFormatter and the GMT offset


  • Subject: Re: NSTimestampFormatter and the GMT offset
  • From: Chuck Hill <email@hidden>
  • Date: Tue, 30 Mar 2010 18:37:51 -0700

You are coming to appreciate why exactly it is that I detest handling date/time.

FB 5 has a new date datatype!


Chuck


On Mar 30, 2010, at 6:35 PM, Pascal Robert wrote:


Le 10-03-30 à 13:39, Pascal Robert a écrit :


Le 10-03-30 à 13:38, Chuck Hill a écrit :

"NSTimestampFormatter is buggy. Do not use it. It will be going away" That is what Mr. Frisch had to say on this a while back.

Try using a SimpleDateFormatter.

Will have to patch ERRest for that :-)

Looks like I'm in Calendar Hell. The tz offset in Dojo have a colon :

	-04:00

but the formatter in java.util. don't accept the colon, the offset should be :

	-0400

So I had to do this :

java.util.regex.Pattern pattern = java.util.regex.Pattern.compile("(.*[\\-,\\+]{1}[0-9]{1,2}):([0-9] {1,2})");
java.util.regex.Matcher matcher = pattern.matcher(strValue);


if (matcher.matches()) {
strValue = matcher.group(1) + matcher.group(2);
parsedValue = new SimpleDateFormat("yyyy-MM- dd'T'HH:mm:ssZ").parseObject(strValue);
if (parsedValue instanceof java.util.Date) {
parsedValue = new NSTimestamp((Date)parsedValue);
}
}


Now I just have to find the best way to patch for this situation.


Chuck



On Mar 30, 2010, at 10:27 AM, Pascal Robert wrote:

I need to send dates from a Dojo app to an ERRest service. Dates constructed by Dojo are like this :

2010-03-30T11:44:34-04:00


They are constructed by toISOString (http://api.dojotoolkit.org/jsdoc/1.2/dojo.date.stamp.toISOString ). So I changed the timestampFormat for ERRest for the following :

er.rest.timestampFormat = %Y-%m-%dT%H:%M:%S%z

But I keep getting :

Caused by: java.lang.IllegalArgumentException: Failed to parse '2010-03-30T11:44:34-04:00' as a timestamp (example: 2010-03-30T11:45:00Z).
at er.rest.ERXRestUtils.coerceValueToTypeNamed(ERXRestUtils.java: 196)
at er.rest.ERXRestUtils.coerceValueToAttributeType(ERXRestUtils.java: 279)
... 15 more
Caused by: java.text.ParseException: Format.parseObject(String) failed
at java.text.Format.parseObject(Format.java:221)
at er.rest.ERXRestUtils.coerceValueToTypeNamed(ERXRestUtils.java: 187)
... 16 more


And it look like the problem is with the "%z" string, if I don't use the GMT offset (so the string ends with "Z" instead of "-04:00"), I don't have this problem. Problem is, I really need the offset. I searched the list and it look like it's a bug with NSTimestampFormatter. I guess one of the solutions would be to use java.util.Date instead of NSTimestamp, but anyone have a better solution?

----
Pascal Robert
email@hidden

AIM: MacTICanada
Twitter : MacTICanada
LinkedIn : http://www.linkedin.com/in/macti
WO Community profile : http://wocommunity.org/page/member?name=probert

_______________________________________________
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

-- Chuck Hill Senior Consultant / VP Development

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


-- Chuck Hill Senior Consultant / VP Development

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


References: 
 >NSTimestampFormatter and the GMT offset (From: Pascal Robert <email@hidden>)
 >Re: NSTimestampFormatter and the GMT offset (From: Chuck Hill <email@hidden>)
 >Re: NSTimestampFormatter and the GMT offset (From: Pascal Robert <email@hidden>)
 >Re: NSTimestampFormatter and the GMT offset (From: Pascal Robert <email@hidden>)

  • Prev by Date: Re: NSTimestampFormatter and the GMT offset
  • Next by Date: One Model and two databses: MySql and Oracle
  • Previous by thread: Re: NSTimestampFormatter and the GMT offset
  • Next by thread: Strange exception with flattened relationship
  • Index(es):
    • Date
    • Thread