GeeCON Prague 2014*
The moose likes Beginning Java and the fly likes how to parse a non-standard Date? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


JavaRanch » Java Forums » Java » Beginning Java
Bookmark "how to parse a non-standard Date?" Watch "how to parse a non-standard Date?" New topic
Author

how to parse a non-standard Date?

Philippe Desrosiers
Ranch Hand

Joined: Mar 29, 2006
Posts: 138
I'm trying to parse a non-standard date string like the following
2008-12-05T10:58:04.197-05:00
. Using a SimpleDateFormat string such as
yyyy-MM-dd'T'HH:mm:ss.SSSZ
won't work because the timezone portion of the date doesn't follow either of the two supported formats. Is there any way to get the formatter to accept this date?
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30595
    
154

Phillipe,
How about converting the string to the standard "-0800" first? You could use a string method call to get rid of the last colon.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Mike Simmons
Ranch Hand

Joined: Mar 05, 2008
Posts: 3016
    
  10
Yeah, what she said.
Philippe Desrosiers
Ranch Hand

Joined: Mar 29, 2006
Posts: 138
Yep. That's what I ended up doing. Just thought there was some more... elegant way to do this. Oh well.

Thanks!
 
Don't get me started about those stupid light bulbs.
 
subject: how to parse a non-standard Date?