Created
June 10, 2021 16:34
-
-
Save superzjn/012112764a45bb30c597ab24a836559f to your computer and use it in GitHub Desktop.
[Current Time] Get current time & timestamp #DateTime
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
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()); | |
} | |
} |
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
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