This works:
public static void main(String[] args) throws Exception {
String s = "01:19 PM";
Date time = null;
DateFormat parseFormat = new SimpleDateFormat("hh:mm a", Locale.ENGLISH);
System.out.println(time = parseFormat.parse(s));
}
ouputs:
Thu Jan 01 13:19:00 KST 1970
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
- SimpleDateFormat ignoring month when parsing
- 12:xx shown as 00:xx in SimpleDateFormat.format(“hh:mm:ss”)
- Convert String to Calendar Object in Java
- SimpleDateFormat parse loses timezone [duplicate]
- SimpleDateFormat parse(string str) doesn’t throw an exception when str = 2011/12/12aaaaaaaaa?
- Comparing time is incorrect when picking 12:00
- Generic support for ISO 8601 format in Java 6
- Converting String to Date using SimpleDateFormat is returning random date [duplicate]
- What are the date formats available in SimpleDateFormat class?
- Displaying AM and PM in lower case after date formatting
- String-Date conversion with nanoseconds
- 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
- SimpleDateFormat with German Locale – Java 8 vs Java 10+
- 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]