LocalDateTimeタイムスタンプ文字列間の変換
762 ワード
1、タイムスタンプLocalDateTime
2、LocalDateTime回転タイムスタンプ
3、dateString回転LocalDateTime
4、LocalDateTime回転dateString
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);
}