Has java any function where I have a String with a date in this form : ddMMyy
or dd.MM.yy
and I want to convert it in another format like: dd:MM:yy
Asked
Active
Viewed 244 times
-3

InfernoVol
- 113
- 1
- 3
- 9
-
[Yes](http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html). – Glorfindel Jul 25 '15 at 15:26
-
Despite its name, [SimpleDateFormat](http://docs.oracle.com/javase/6/docs/api/java/text/SimpleDateFormat.html) both parses and formats dates and times. – fvu Jul 25 '15 at 15:26
-
some code would be nice :) – InfernoVol Jul 25 '15 at 15:28
-
@InfernoVol Some [searching before posting](http://stackoverflow.com/search?q=Java+date+format) would be nice. – Basil Bourque Jul 25 '15 at 18:29
1 Answers
1
I would suggest using two SimpleDateFormat objects for this.
Date date = new SimpleDateFormat("ddMMyy").parse( dateString);
String result = new SimpleDateFormat("dd:MM:yy").format( date );
For the format, see the documentation: http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html

Florian Schaetz
- 10,454
- 5
- 32
- 58