Convert date from string "yyyyddmm hh:mm:ss" to String "DD/MM/YYYY" in JAVA -
Can anyone help me with this conversion?
string datetime = "20140505 03:23:50" dateform formattor = new simpledetermut format ("DD / MM / Yay"); String date = formater. Format (datetime);
I should have output in this format - "DD / MM / YYYY" which should be a string.
You have to:
string dateTime = "20140505 03 : 23: 50 "; DateFormat formatter = New SimpleDormat ("YYMMMD HH: mm: SS"); Date date = formatter.parse (dateTime); Formatte.applyPattern ("dd / mm / yyyy"); String date srr = formater Format (date);
Before you change formatter.parse (string)
by using your string
from the date
object On your string
pattern, and then you can change your date
in any string
format by changing your SimpleDateFormat
pattern Are there.
Note: D:
in the year and d:
in the day < / D
instead of D
.
You can use the correctness of the pattern in Java to format the date according to your requirement.
Comments
Post a Comment