-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathZoneIdExamples.java
More file actions
44 lines (38 loc) · 1.24 KB
/
ZoneIdExamples.java
File metadata and controls
44 lines (38 loc) · 1.24 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
import java.time.LocalTime;
import java.time.ZoneId;
import java.time.format.TextStyle;
import java.util.Locale;
public class ZoneIdExamples {
public static void main(String[] args) {
System.out.println("Zone Id Example");
zoneIdExample();
System.out.println("Zone Id System Default Example");
zoneIdSystemDefaultExample();
System.out.println("Zone Id Get Id Example");
zoneIdGetIdExample();
System.out.println("Zone Id Get Display Name Example");
zoneIdGetDisplayName();
}
public static void zoneIdExample(){
ZoneId zoneid1 = ZoneId.of("Asia/Kolkata");
ZoneId zoneid2 = ZoneId.of("Asia/Tokyo");
LocalTime id1 = LocalTime.now(zoneid1);
LocalTime id2 = LocalTime.now(zoneid2);
System.out.println(id1);
System.out.println(id2);
System.out.println(id1.isBefore(id2));
}
public static void zoneIdSystemDefaultExample(){
ZoneId zone = ZoneId.systemDefault();
System.out.println(zone);
}
public static void zoneIdGetIdExample(){
ZoneId z = ZoneId.systemDefault();
String s = z.getId();
System.out.println(s);
}
public static void zoneIdGetDisplayName(){
ZoneId z = ZoneId.systemDefault();
System.out.println(z.getDisplayName(TextStyle.FULL, Locale.ROOT));
}
}