标签:eid ring pat div params pattern tar 分享图片 code
1. 把yyyyMMddHHmmss 变成date型
String startTime = params.get("startTime").toString(); DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyyMMddHHmmss"); LocalDateTime startLocalDate = LocalDateTime.parse(startTime,dtf); ZoneId zone = ZoneId.systemDefault(); Instant sInstant = startLocalDate.atZone(zone).toInstant(); Date startDate = Date.from(sInstant);
System.out.println(startDate);
最终结果:
2.把yyyy-MM-dd HH:mm:ss变成date型
String dispatchTime = workOrderInfo.get("DISPATCH_TIME"); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); ParsePosition pos = new ParsePosition(0); Date dispatchTimeDate = sdf.parse(dispatchTime, pos);
最终结果:
标签:eid ring pat div params pattern tar 分享图片 code
原文地址:https://www.cnblogs.com/linhongwenBlog/p/9111838.html