Skip to content

Instantly share code, notes, and snippets.

@donchan922
Last active September 16, 2018 13:56
Show Gist options
  • Save donchan922/b26aae8bdefc6de82ce98185605ff4ff to your computer and use it in GitHub Desktop.
Save donchan922/b26aae8bdefc6de82ce98185605ff4ff to your computer and use it in GitHub Desktop.
Use of Instant class for java 8
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