We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent e4db572 commit 8c24e35Copy full SHA for 8c24e35
src/main/java/com/rampatra/java8/DateTime.java
@@ -0,0 +1,29 @@
1
+package com.rampatra.java8;
2
+
3
+import java.time.Instant;
4
+import java.time.LocalDateTime;
5
+import java.time.ZoneId;
6
+import java.util.Date;
7
8
+/**
9
+ * @author rampatra
10
+ * @since 2019年05月15日
11
+ */
12
+public class DateTime {
13
14
+ private static long getCurrentTimestampFromInstant() {
15
+ return Instant.now().toEpochMilli();
16
+ }
17
18
+ private static String addTwoDays() {
19
+ LocalDateTime now = LocalDateTime.ofInstant(Instant.now(), ZoneId.of("UTC"));
20
+ LocalDateTime afterTwoDays = now.plusDays(2);
21
+ return afterTwoDays.getDayOfMonth() + "-" + afterTwoDays.getMonthValue() + "-" + afterTwoDays.getYear();
22
23
24
+ public static void main(String[] args) {
25
+ System.out.println("Timestamp from Instant: " + getCurrentTimestampFromInstant() +
26
+ "\nTimestamp from Legacy Date: " + new Date().getTime());
27
+ System.out.println("Add Two days: " + addTwoDays());
28
29
+}
AltStyle によって変換されたページ (->オリジナル) / アドレス: モード: デフォルト 音声ブラウザ ルビ付き 配色反転 文字拡大 モバイル
0 commit comments