This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Convert String to Java Date

 
ryan bohnert
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
Campbell Ritchie
Sheriff
Posts: 48363
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic