1、时间戳转LocalDateTime
2、LocalDateTime转时间戳
3、dateString 转 LocalDateTime
4、LocalDateTime转dateString
public static void main(String[] args) {
Long time = 1562983881098L;
LocalDateTime time2 = LocalDateTime.ofEpochSecond(time / 1000, 0, ZoneOffset.ofHours(8));
System.err.println(time2);
DateTimeFormatter df = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
String localTime = df.format(time2);
System.err.println(time2);
LocalDateTime ldt = LocalDateTime.parse("2018-01-12 17:07:05", df);
System.out.println("LocalDateTime转成String类型的时间:" + localTime);
System.out.println("String类型的时间转成LocalDateTime:" + ldt);
}