<分区>
错误(java.text.ParseException:无法解析的日期:“2017 年 11 月 2 日 09:44:00:000AM”)
这是我的代码,我在 fragment 上使用它
String tanggal = dataObject.getString("tgl_periksa");
DateFormat readFormat = new SimpleDateFormat("MM dd yyyy HH:mm:ss:SSSa");
DateFormat writeFormat = new SimpleDateFormat( "yyyy-MM-dd HH:mm:ss");
Date date = null;
try {
date = readFormat.parse( tanggal );
} catch ( ParseException e ) {
e.printStackTrace();
}
String formattedDate = "";
if( date != null ) {
formattedDate = writeFormat.format( date );
}