• Post Reply Bookmark Topic Watch Topic
  • New Topic

Date conversion Q.  RSS feed

 
Dylan Lorimerer
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I have a date in a string as such: 2000-Feb-2 18:37:44+02
I want to convert it to: 2000-02-02 18:37:44+02 by any means necessary.

It looks like I might want to use DateFormat but then I see Calendar and I'm getting confused. If anyone knows the best class and/or function I would be very appreciative. Code for that matter would be a life saver!

Cheers.
 
Stan James
(instanceof Sidekick)
Ranch Hand
Posts: 8791
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can use DateFormat to parse a string into a Calendar object, and another DateFormat to format the Calendar back into another String.

You could also split() the string on hyphens, find the "Feb" part, look up "02" in a map and put the string back together. But the date stuff is much more elegant.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!