我正在尝试使用以下代码解析android中的日期
java.text.ParseException: Unparseable date: "Sun Apr 15 13:37:33 CEST 2012" (at offset 20)
上面的代码适用于java,但在Android中它提供了ParseException。
session_start()
可能的原因是什么?
我在Samsung S4上运行它,棒棒糖,系统语言是法语,系统时区是GMT + 2:00。
答案 0 :(得分:0)
试试这段代码:
String mytime="Jan 17, 2012";
SimpleDateFormat dateFormat = new SimpleDateFormat(
"MMM dd, yyyy");
Date myDate = null;
try {
myDate = dateFormat.parse(mytime);
} catch (ParseException e) {
e.printStackTrace();
}
SimpleDateFormat timeFormat = new SimpleDateFormat("EEE MMM dd HH:mm:ss
zzz yyyy");
String finalDate = timeFormat.format(myDate);
TextView t = (TextView) findViewById(R.id.txt);
t.setText(finalDate);