为什么时间输出结果不一样,求解
package com.imooc;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
public class TheLise {
public static void main(String[] args)throws ParseException {
SimpleDateFormat sb1=new SimpleDateFormat("yyyy年MM月dd日HH时mm分ss秒");
SimpleDateFormat sb2=new SimpleDateFormat("yyyy/mm/dd HH:mm");
SimpleDateFormat sb3=new SimpleDateFormat("yyyy-mm-dd HH:mm:ss");
Date b=new Date();
System.out.println(sb1.format(b));
System.out.println(sb2.format(b));
System.out.println(sb3.format(b));
String d="2019-7-6 16:07:13";
SimpleDateFormat sb4=new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date sb6=sb4.parse(d);
System.out.println(sb6);
}结果
2019年07月24日17时34分50秒
2019/34/24 17:34
2019-34-24 17:34:50
Exception in thread "main" java.text.ParseException: Unparseable date: "2019-7-6 16:07:13"
at java.text.DateFormat.parse(DateFormat.java:366)
at com.imooc.TheLise.main(TheLise.java:17)
Process finished with exit code 1
需要trycatch起来