I have noticed a discrepancy in Android's SimpleDateFormat
for reading milliseconds for my formatter between Android 4.x and 5.0.
String dateString = "2012-10-01 00:00:00.000087";
// ORMLite date format as seen at https://github.com/j256/ormlite-core/blob/master/src/main/java/com/j256/ormlite/field/types/BaseDateType.java
SimpleDateFormat formatForDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss.SSSSSS");
try{
Date parsedDate = formatForDate.parse(dateString);
// Android 5.0 parsedDate.getTime() ends in 000
// Android 4.x parsedDate.getTime() ends in 087 as expected
}
catch (ParseException e) {
e.printStackTrace();
}
As explained in the comments, when running above code on android 4.x I get different results than when I do on Android 5.0. It seems to discard the MS field for Android 5.
(When I change the format to end in .SSS
and change the value to drop extra zeros to be just 087
the date gets parsed correctly on Android 5.0. This isn't a great workaround as all my database fields are saved in the SSSSSS
format, as is ORMLite's default.)
I can't seem to find changes that Google has made in SimpleDateFormat
code. What would cause a problem lilke this? Where might I look for a fix?