//日期—文本
Date date = new Date();
SimpleDateFormat sdf = new SimpleDateFormat();
String format = sdf.format(date);
System.out.println(format);
//默认
//改变默认
sdf = new SimpleDateFormat(“y-M-d”);
String format2 = sdf.format(date);
System.out.println(format);
//文本—日期
sdf = new SimpleDateFormat(“y年m月d日”);
String strdate =“2019年9月9日”;
Date parse = sdf.parse(strdate);
System.out.println(parse);
//文本到日期:格式要匹配,不能有空格
//格式长度,大于字符串长度,没法解析
//(sdf)小于字符串长度,可以解析