One possibility is that your default Locale
has different symbols for AM/PM. When constructing a date format you should always supply a Locale
unless you really want to use the system’s default Locale
, e.g.:
SimpleDateFormat sdf = new SimpleDateFormat("M/d/yy h:mm:ss a", Locale.US)
More Related Contents:
- How to parse a date? [duplicate]
- Java – Unparseable date
- How do you format the day of the month to say “11th”, “21st” or “23rd” (ordinal indicator)?
- Illegal pattern character ‘T’ when parsing a date string to java.util.Date
- Why is Java’s SimpleDateFormat not thread-safe? [duplicate]
- java.text.ParseException: Unparseable date
- SimpleDateFormat producing wrong date time when parsing “YYYY-MM-dd HH:mm”
- How to convert a String to a Date using SimpleDateFormat?
- How does Java “week year” really work?
- Parsing ISO 8601 date format like 2015-06-27T13:16:37.363Z in Java [duplicate]
- Date object SimpleDateFormat not parsing timestamp string correctly in Java (Android) environment
- Changing String date format
- Java Date year calculation is off by year for two days
- How to parse month full form string using DateFormat in Java?
- SimpleDateFormat parse loses timezone [duplicate]
- SimpleDateFormat parse(string str) doesn’t throw an exception when str = 2011/12/12aaaaaaaaa?
- Java Convert GMT/UTC to Local time doesn’t work as expected
- How to convert date in to yyyy-MM-dd Format?
- Comparing time is incorrect when picking 12:00
- Generic support for ISO 8601 format in Java 6
- Displaying AM and PM in lower case after date formatting
- String-Date conversion with nanoseconds
- How to convert HH:mm:ss.SSS to milliseconds?
- how to add days to java simple date format
- SimpleDateFormat giving wrong date instead of error
- How to Parse Date from GMT TimeZone to IST TimeZone and Vice Versa in android
- Java SimpleDateFormat Timezone offset with minute separated by colon
- java.text.ParseException: Unparseable date: “01:19 PM”
- Is SimpleDateFormat in Java work incorrect or I did any mistake? See code sample [duplicate]
- Java SimpleDateFormat pattern for W3C XML dates with timezone [duplicate]