aspose file tools
The moose likes Beginning Java and the fly likes Convert String to Java Date Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply 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: 15
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: 32638
    
    4
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: http://aspose.com/file-tools
 
subject: Convert String to Java Date
 
Similar Threads
Converting from string to date
Convert Local time to UTC and vice versa
Problems handling the Date Class.
problem while insert date data in mysql
Convert milliseconds to time