ParseException when parsing 3 character abbreviated month using SimpleDateFormat
问题 Here is my code, SimpleDateFormat format = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss"); Date dft = (Date) format.parse("16-MAY-2018 09:30:22:000"); I am getting below exception java.text.ParseException: Unparseable date: "16-MAY-2018 09:30:22" What's to be used to parse milliseconds? 回答1: The pattern should be MMM because there are three characters in the month. You should also prefer java.time classes to the ones you're currently using if you're on Java 8 or above: DateTimeFormatter