wood burning stoves 2.0*
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


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Convert String to Java Date" Watch "Convert String to Java Date" New topic
Author

Convert String to Java Date

ryan bohnert
Greenhorn

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.548GMT-06:00
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
Sheriff

Joined: Oct 13, 2005
Posts: 37884
    
  22
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Convert String to Java Date
 
Similar Threads
Convert Local time to UTC and vice versa
Convert milliseconds to time
problem while insert date data in mysql
Converting from string to date
Problems handling the Date Class.