packageapm.weather.utils;importjava.text.ParseException;importjava.text.SimpleDateFormat;importjava.util.Date;publicclasstest{publicstaticvoidmain(String[]args){SimpleDat...
package apm.weather.utils;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class test {
public static void main(String[] args) {
SimpleDateFormat formatter = new SimpleDateFormat("dd MMM yyyy");
String dataStr = "27 Nov 2018";
try {
Date date = formatter.parse(dataStr);
System.out.println(date.toString());
} catch (ParseException e) {
e.printStackTrace();
}
}
}
-------------------------错误如下--------------------------------
java.text.ParseException: Unparseable date: "7-Nov-2015"
at java.text.DateFormat.parse(DateFormat.java:366)
at apm.weather.utils.test.main(test.java:26)
这个错误提示才是
java.text.ParseException: Unparseable date: "27 Nov 2018"
at java.text.DateFormat.parse(DateFormat.java:366)
at apm.weather.utils.test.main(test.java:14)
展开