We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent c78b310 commit eb2d38aCopy full SHA for eb2d38a
1 file changed
datetime/JavaDateTimeArithmetic.java
@@ -0,0 +1,23 @@
1
+package com.zetcode;
2
+
3
+import java.time.LocalDate;
4
+import static java.time.temporal.ChronoUnit.DAYS;
5
6
+public class JavaDateTimeArithmetic {
7
8
+ public static void main(String[] args) {
9
10
+ LocalDate now = LocalDate.now();
11
+ LocalDate ndate1 = now.plusDays(30);
12
13
+ System.out.println(ndate1);
14
15
+ LocalDate ndate2 = now.minusWeeks(15);
16
+ System.out.println(ndate2);
17
18
19
+ LocalDate newYear = LocalDate.of(2018, 1, 1);
20
+ long dif = DAYS.between(newYear, now);
21
+ System.out.printf("Days passed since beginning of 2018: %d%n", dif);
22
+ }
23
+}
0 commit comments