You could try to parse them (for example with SimpleDateFormat) and format the resulting Date object again, but that is probably not the most efficient way. You could just use methods in class String to get the parts that you need and paste them together again.
Efficiency is overrated, I think. For most programs, IO/database operations are the slowest by far, and the speed of anything else is unimportant. I would try to make the method as easy as possible to understand and modify later if necessary - to do this, SimpleDateFormat is the way to go. It may be a little bit slower than the method Jesper suggests, but the chance that this will ever matter is remarkably small. [ February 16, 2008: Message edited by: Jim Yingst ]
"I'm not back." - Bill Harding, Twister
Joined: May 30, 2005
Is there any way to do this in reverse?
e.g. you have a date along the lines of 2008-02-19.
How would you end up with a String with something like 20080219 ??
Joined: Mar 22, 2005
Originally posted by Aaron John: Is there any way to do this in reverse?
That's really the same problem, isn't it? You can either use SimpleDateFormat or string operations.