第一种:2022-03-03 22:40
Date current = new Date();
java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat("yyyy-MM-dd HH:mm");
String time = sdf.format(current);
System.out.println(time);//2022-03-03 22:40
第二种:2022年03月03日 22时43分
SimpleDateFormat sdf = new SimpleDateFormat("yyyy年MM月dd日 HH时mm分");
try {
Date date = new Date();
String dateStringParse = sdf.format(date);
System.out.println(dateStringParse);//2022年03月03日 22时43分
} catch (Exception e) {
e.printStackTrace();
}