DateFormat d2 = new SimpleDateFormat("yyyy-MM-dd");
DateFormat d3 = new SimpleDateFormat("yyyy年MM月dd日");
DateFormat d4 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date();
String s2 = d2.format(date);
String s3 = d3.format(date);
String s4 = d4.format(date);
输出结果:
2021-03-01
2021年03月01日
2021-03-01 15:13:19