我從 api 服務(wù)器中獲取一些數(shù)據(jù),包含數(shù)據(jù)和數(shù)據(jù)格式2013-09-06T14:15:11.557。這是什么格式呢?如何把這個數(shù)據(jù)格式轉(zhuǎn)換為2013 sept 06 2:15我使用下面2中方法來轉(zhuǎn)換日期格式public static Date stringToDate(String dateString)
{
Date date = null;
DateFormat df = new SimpleDateFormat(Constants.DATE_FORMAT_WITHOUT_TIME);
try {
date = df.parse(dateString);
} catch (ParseException e) {
e.printStackTrace();
}
return date;
}和public static String FormatDate(String dateString)
{
String s="";
Date date = stringToDate(dateString);
s = date.getDate()+" "+monthname[date.getMonth()+1]+" "+(date.getYear()+1900);
return s;
}這是我的數(shù)據(jù)格式常量public static final String DATE_FORMAT_WITHOUT_TIME = "yyyy-MM-dd";,但是解析的不正確。
添加回答
舉報
0/150
提交
取消