Skip to content

Commit 3ac2c7f

Browse files
authored
Create LocalDateTimeTest.java
1 parent 4f2cb76 commit 3ac2c7f

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
/**
2+
*
3+
*/
4+
package localdatetimeexamples;
5+
6+
import java.time.LocalDate;
7+
import java.time.LocalDateTime;
8+
import java.time.ZoneId;
9+
import java.time.ZonedDateTime;
10+
11+
/**
12+
* @author rutpatel
13+
*
14+
*/
15+
public class LocalDateTimeTest {
16+
17+
public static void main(String[] args) {
18+
19+
LocalDateTime ldt = LocalDateTime.now();
20+
LocalDate ld = LocalDate.now();
21+
22+
System.out.println(ldt + " " + ld);
23+
24+
System.out.println(ld.plusDays(20));
25+
26+
ZonedDateTime zdt = ZonedDateTime.now();
27+
ZoneId zid = ZoneId.of("Asia/Kolkata");
28+
29+
ZonedDateTime indiaDateTime = zdt.toInstant().atZone(zid);
30+
31+
System.out.println(zdt + "\n" + indiaDateTime);
32+
}
33+
}

0 commit comments

Comments
 (0)