import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class formatTest {
public static void main(String[] args){
String str = "2017-08-07 6:6:6";
SimpleDateFormat sdf = new SimpleDateFormat("YYYY-MM-dd HH:mm:ss");
try {
Date d = sdf.parse(str);
Date date = sdf.parse(str);
} catch (ParseException e) {
e.printStackTrace();
}
}
}
答案 0 :(得分:1)
将YYYY更改为yyyy
String str = "2017-08-07 06:06:06";
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");