日期字符格式yyyyMMddHHmmss转换字符串或LocalDateTime对象
字符串yyyyMMddHHmmss转换字符串 格式
public static String stringToDateStringSimpleV2(String str) { //使用新的方式转换时间 LocalDateTime date = LocalDateTime.parse(str, DateTimeFormatter.ofPattern("yyyyMMddHHmmss")); return date.format(DateTimeFormatter.ofPattern("yyyy.MM.dd")); } public static String stringToDateStringV2(String str) { //使用新的方式转换时间 LocalDateTime date = LocalDateTime.parse(str, DateTimeFormatter.ofPattern("yyyyMMddHHmmss")); return date.format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss")); }
字符串yyyyMMddHHmmss转换LocalDateTime
public static LocalDateTime stringToLocalDateTime(String str) { //使用新的方式转换时间 LocalDateTime date = LocalDateTime.parse(str, DateTimeFormatter.ofPattern("yyyyMMddHHmmss")); return date; }
标签:String,ofPattern,date,str,LocalDateTime,字符串,yyyyMMddHHmmss From: https://www.cnblogs.com/oktokeep/p/18574965