0
我使用的是功能可按的Android无法解析日期:2017年1月6日
public static String getFormatedDate(String dateVal) {
String tempDate = null;
Locale systemLocale = Locale.getDefault();
try {
SimpleDateFormat formatter = new SimpleDateFormat("MMM dd, yyyy",
systemLocale);
Date date = (Date) formatter.parse(dateVal);
SimpleDateFormat sdf = new SimpleDateFormat("MM/dd/yyyy");
tempDate = sdf.format(date);
} catch (Exception e) {
ApplicationLog.log(TAG, e);
}
return tempDate;
}
在这个功能是否正常工作很多设备,但在设备之一,在分析日的异常被提出。这个异常是否与Locale.getDefault()
有关?如果是,我应该做什么改变?谢谢。
调用函数
Utilities.getFormatedDate(date);
而例外的是...
Utilities:java.text.ParseException: Unparseable date: "Jan 06, 2017" (at offset 0)
at java.text.DateFormat.parse(DateFormat.java:579)
你可以发布整个堆栈跟踪吗? –
你也可以分享你调用这个方法的代码吗? –
是的,你是对的。只是尝试不传递语言环境。 –