Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

I got date as '14-Dec-2010' i want to get the month in number format for the given date. that is., i want to convert the date to '14-12-2010'.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
127 views
Welcome To Ask or Share your Answers For Others

1 Answer

DateFormat inFm = new SimpleDateFormat("d-MMM-y");
DateFormat outFm = new SimpleDateFormat("d-M-yyyy");
Date date = inFm.parse("14-Dec-2010");
String output = outFm.format(date);

Generally, you should use a datetime type like Date internally, then transform to String at output time.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...