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 Android Security Essentials Live Lessons this week in the Android 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: 38064
    
  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.
 
 
subject: Convert String to Java Date
 
Similar Threads
Convert Local time to UTC and vice versa
Convert milliseconds to time
Problems handling the Date Class.
problem while insert date data in mysql
Converting from string to date