Skip to content

Commit d6714d8

Browse files
committed
📝 update datetimeapi example
1 parent c710029 commit d6714d8

File tree

1 file changed

+23
-0
lines changed

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package io.github.biezhi.datetime;
2+
3+
import java.time.Clock;
4+
import java.time.Instant;
5+
import java.util.Date;
6+
7+
/**
8+
* Clock 示例
9+
*
10+
* @author biezhi
11+
* @date 2018/3/3
12+
*/
13+
public class ClockExample {
14+
15+
public static void main(String[] args) {
16+
Clock clock = Clock.systemDefaultZone();
17+
long millis = clock.millis();
18+
Instant instant = clock.instant();
19+
Date legacyDate = Date.from(instant); // legacy java.util.Date
20+
System.out.println(millis);
21+
System.out.println(legacyDate);
22+
}
23+
}

0 commit comments

Comments
 (0)