Last active
September 16, 2018 13:56
-
-
Save donchan922/b26aae8bdefc6de82ce98185605ff4ff to your computer and use it in GitHub Desktop.
Use of Instant class for java 8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.time.*; | |
public class Main { | |
public static void main(String[] args) { | |
// 現在日時を取得(エポック時間) | |
Instant i1 = Instant.now(); // -> 2018-09-16T13:24:09.496Z | |
// long -> Instant | |
Instant i2 = Instant.ofEpochMilli(1537104249489L); // -> 2018-09-16T13:24:09.489Z | |
// Instant -> long | |
long l = i2.toEpochMilli(); // -> 1537104249489 | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment