File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Beginning Java and the fly likes Convert String to Java Date Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Convert String to Java Date" Watch "Convert String to Java Date" New topic

Convert String to Java Date

ryan bohnert

Joined: Feb 27, 2008
Posts: 19
I am trying to convert a string to Java Date.

java.text.ParseException: Unparseable date: "2008-04-22T09:00:10.548-06:00"

Any suggestions?
Wouter Oet
Saloon Keeper

Joined: Oct 25, 2008
Posts: 2700

You're parse string should be

2008-04-22T09:00:10.548Pacific Standard Time-06:00

or something like that.

"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 42566
Go through the SimpleDateFormat documentation. When you get to the Z bit for time zone, the example shown has -0800, not -08:00. It is different if you write z from if you write Z.
I agree. Here's the link:
subject: Convert String to Java Date