JAVA8 LocalDateTime
2021-05-06 16:28
标签:mes color span now() str epo eof ant off JAVA8 LocalDateTime 标签:mes color span now() str epo eof ant off 原文地址:https://www.cnblogs.com/bors/p/LocalDateTime.htmlLocalDateTime String
//时间转字符串格式化
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMddHHmmssSSS");
String dateTime = LocalDateTime.now(ZoneOffset.of("+8")).format(formatter);
//字符串转时间
String dateTimeStr = "2018-07-28 14:11:15";
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
LocalDateTime dateTime = LocalDateTime.parse(dateTimeStr, df);
LocalDateTime获取毫秒数
//获取秒数
Long second = LocalDateTime.now().toEpochSecond(ZoneOffset.of("+8"));
//获取毫秒数
Long milliSecond = LocalDateTime.now().toInstant(ZoneOffset.of("+8")).toEpochMilli();
文章标题:JAVA8 LocalDateTime
文章链接:http://soscw.com/index.php/essay/83290.html