JAVA时间转换总结
1.格式化时间 Date ~ 2022-03-24 03:30:13
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String dateStr = format.format(new Date());
2.格式化时间 2022-03-24T03:30:13.000000 ~ 2022-03-24 03:30:13
SimpleDateFormat format = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
String createAt = "2022-03-24T03:30:13.000000".replace("T", " ");
Date date;
Calendar cal = Calendar.getInstance();
try {
date = format.parse(createAt);
cal.setTime(date);
} catch (ParseException e) {
System.out.println("portalDateToStr error:" + e);
}
Date calTime = cal.getTime();
String formatRs = format.format(date);
标签:总结,03,转换,format,30,SimpleDateFormat,date,Date,JAVA From: https://www.cnblogs.com/minaotor/p/18412164