I have encountered an issue with date formatting on Android 6.0, Marshmallow. The code throwing the exception noted below is a pure-Java library (built separately) which my
The UK Locale appears to have had its definitions of "am" and "pm" altered.
In Marshmallow the UK Locale now has "am" represented as "a.m." and "pm" by "p.m."
String record = "2015-10-23 Fri 10:59 p.m. BST 3.60 meters"
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd E hh:mm aa", Locale.UK);
// note the length is 25 now, not 23...
Date eventDate = dateFormat.parse(StringUtils.substring(record, 0, 25).trim());
I can't offer an explanation why, but the US Locale works with am/pm and the UK with a.m./p.m.
Edit
It appears that as part of the Locale updates in March 2015, the en_gb
locale had its am/pm definitions replaced. source diff