//1、创建Date对象Datedate=newDate();
//2.格式化需要使用SimpleDateFormat//使用SimpleDateFormat需要给一个时间模式
SimpleDateFormat sf =new SimpleDateFormat();
//3、调用format()方法完成格式化String time = sf.format(date);
System.out.println(date);
日期解析
就是String转Date;通过parse()完成
//注意:解析的时间模式要跟给定的String格式一样
Stringtime ="2017-03-21 17:30:30";
SimpleDateFormat sf = new SimpleDateFormat("yyy-MM-dd HH:mm:ss");
Date date = sf.parse(time);
System.out.println(date);
日期格式化就是将Date转String;通过format()完成//1、创建Date对象Date date = new Date();//2.格式化需要使用SimpleDateFormat//使用SimpleDateFormat需要给一个时间模式SimpleDateFormat sf = new SimpleDateFormat();//3、调用format()方法完成格式化Stri