Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

puzzled with how to convert ddmmyy string to dd-MMM-yy date

Tags:

java

date

I am puzzled with how to convert ddmmyy string to dd-MMM-yy date in java code.Example--

041110 as a string will be 04-NOV-10 as date.

Any suggestion will be greatly appreciated.

Thanks.

like image 866
godin Avatar asked Dec 12 '22 11:12

godin


2 Answers

Using SimpleDateFormat

Something like

DateFormat input = new SimpleDateFormat("ddMMyy");
DateFormat output = new SimpleDateFormat("dd-MMM-yy");
String result = output.format(input.parse(inputString));
like image 94
jmj Avatar answered Dec 21 '22 22:12

jmj


Why not use SimpleDateFormat?

like image 21
RMT Avatar answered Dec 21 '22 23:12

RMT