Skip to content

Instantly share code, notes, and snippets.

@superzjn
Created June 10, 2021 16:34
Show Gist options
  • Save superzjn/012112764a45bb30c597ab24a836559f to your computer and use it in GitHub Desktop.
Save superzjn/012112764a45bb30c597ab24a836559f to your computer and use it in GitHub Desktop.
[Current Time] Get current time & timestamp #DateTime
package com.shxt.demo02;
import java.time.LocalTime;
public class Demo06 {
public static void main(String[] args) {
LocalTime time = LocalTime.now();
System.out.println("获取当前的时间,不含有日期:"+time);
Clock clock = Clock.systemUTC();
System.out.println("Clock : " + clock.millis());
Clock defaultClock = Clock.systemDefaultZone();
System.out.println("Clock : " + defaultClock.millis());
}
}
package com.shxt.demo02;
import java.time.Instant;
public class Demo16 {
public static void main(String[] args) {
Instant timestamp = Instant.now();
System.out.println("What is value of this instant " + timestamp.toEpochMilli());
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment