SimpleDateFormat sdf =new SimpleDateFormat("yyyy-MM-dd"); //定义格式化规则
Date date = new Date(); //Mon Aug 01 15:17:21 CST 2016
System.out.println(sdf.format(date)); //2016-08-01 将日期装换成字符串形式
String stringdate ="2016-08-01";
System.out.println(sdf.parse(stringdate)); //Mon Aug 01 00:00:00 CST 2016 将字符串装换成日期形式
Date date = new Date(); //Mon Aug 01 15:17:21 CST 2016
System.out.println(sdf.format(date)); //2016-08-01 将日期装换成字符串形式
String stringdate ="2016-08-01";
System.out.println(sdf.parse(stringdate)); //Mon Aug 01 00:00:00 CST 2016 将字符串装换成日期形式