Convert JSON date in the "mm dd yyyy" format
In my application the Date Fiend JSON response comes as this type:
"CreatedOn": "/Date(1313572467987+0000)/"
I want to convert this date in the "MM DD YYYY" format. How can I convert this?
That date in your JSON response looks like a standard timestamp (eg number of milliseconds since January 1, 1970). If you parse out the timestamp something like:
String timestamp = jsonValue.split("(")[1].split("+")[0];
Date createdOn = new Date(Long.parseLong(timestamp));
Now you can use SimpleDateFormat to format a date string:
SimpleDateFormat sdf = new SimpleDateFormat("MM dd yyyy");
String formattedDate = sdf.format(createdOn);
This is ignoring the timezone adjustment in that response (the '+0000') you might also want to parse out this value and add/remove the hours from your timestamp value before formatting..
you can use SimpleDateFormat , so just try to search on the same.
Detailed example is here: http://www.helloandroid.com/tutorials/date-handling-android-development
链接地址: http://www.djcxy.com/p/46654.html上一篇: JSON日期格式看起来不同