aspose file tools*
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
internet detective
Marshal

Joined: May 26, 2003
Posts: 30309
    
150

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: 3007
    
    9
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!
 
Consider Paul's rocket mass heater.
 
subject: how to parse a non-standard Date?