-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTimeClass.java
More file actions
51 lines (46 loc) · 1.64 KB
/
TimeClass.java
File metadata and controls
51 lines (46 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package DateTime;
import java.util.Date;
import java.time.*;
public class TimeClass {
public static void main(String[] args) {
Date date = new Date();
date.setHours(1);
date.setDate(6);
System.out.println(date);
LocalDate Ld = LocalDate.now(Clock.systemDefaultZone());
System.out.println(Ld);
Ld = LocalDate.now(ZoneId.of("Pacific/Apia"));
System.out.println(Ld);
Ld = LocalDate.of(2021,Month.NOVEMBER,15);
System.out.println(Ld);
Ld = LocalDate.ofEpochDay(5);
System.out.println(Ld);
Ld = LocalDate.parse("2019-02-28");
System.out.println(Ld);
LocalDate LdNew = Ld.plusMonths(2);
//LocalDate is immutable class
System.out.println(LdNew);
LocalTime Lt = LocalTime.now();
System.out.println(Lt);
LocalTime LtNew = Lt.minusHours(5);
// LocalTime Immutable Class
System.out.println(LtNew);
ZonedDateTime ZDT = ZonedDateTime.now(ZoneId.of("Pacific/Apia"));
System.out.println(ZDT);
OffsetDateTime ODT = OffsetDateTime.now(ZoneId.of("America/Los_Angeles"));
System.out.println(ODT);
MonthDay MD = MonthDay.now();
LocalDate qa = MD.atYear(2021);
System.out.println(qa);
YearMonth YM = YearMonth.now();
System.out.println(YM);
Year Y = Year.now();
System.out.println(Y);
Period P = Period.of(2202,02,05);
System.out.println(P.addTo(LocalDate.now()));
Instant I = Instant.now();
System.out.println(I);
Duration D = Duration.ofDays(1);
System.out.println(D);
}
}