I got a String in hand in this format: yyyymmdd, for example: 19821117 or 19540227. I would like to turn it into a readable date in this format: dd.mm.yyyy. So 19821117 for example would be converted to: 17.11.1982. I don't need the result to be a valid Date object, a String is also fine. Any ideas...?
Joined: Mar 22, 2005
That's what the java.text.SimpleDateFormat class does. Its parse method converts a String (in a given format) to a Date, while format converts a Date to a String.
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Joined: Oct 17, 2006
Thanks for the tip, I am familiar with SimpleDateFormat. The problem is that when I create one: SimpleDateFormat formatter = new SimpleDateFormat("dd.MM.yyyy"); And than format my String I get: "Cannot format given Object as a Date" So, can someone please show me a working code example?
Thanks, Roy [ August 08, 2007: Message edited by: Roy Cohen ]