开发者

how do i change the format of a string representing time in android?

I have a string which i retrieve from the database which is of the foll开发者_如何转开发owing format

30-08-2010 12:30:00

i need to convert that string into the following format

Aug 30 2010 12:30 PM

How do i do this? Also tell me how to convert the string into a date object.

thank you in advance.


look around java.util.* for more info. It has nothing to do with Android.

DateFormat formatter1 = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");

Date date = (Date)formatter1.parse("30-08-2010 12:30:00");   

DateFormat formatter2 = new SimpleDateFormat("MMM dd yyyy hh:mm a");
String newFormattedString = formatter2.format(date);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜