Jdk1.8日期格式转换小笔记

yyyy-MM-ddHH:mm
String inqStartTime = "2020-04-1300:00"; 
String inqEndTime = "2020-04-1323:59"   
/**************日期格式转换:yyyy-MM-ddHH:mm -》 yyyyMMddHHmm ****************/
DateTimeFormatter dateTimeFormatterOrigin = DateTimeFormatter.ofPattern("yyyy-MM-ddHH:mm");
LocalDateTime inqStartTimeLDT = LocalDateTime.parse(inqStartTime, dateTimeFormatterOrigin);
LocalDateTime inqEndTimeLDT = LocalDateTime.parse(inqEndTime, dateTimeFormatterOrigin);

DateTimeFormatter dateTimeFormatterNeeded = DateTimeFormatter.ofPattern("yyyyMMddHHmm");

inqStartTime = dateTimeFormatterNeeded.format(inqStartTimeLDT);
inqEndTime = dateTimeFormatterNeeded.format(inqEndTimeLDT);

/**************日期格式转换:yyyy-MM-dd-HH:mm -》 yyyyMMddHHmm****************/

 

你可能感兴趣的:(个人笔记)