NebulaGraph Java Client 5.0.0
Loading...
Searching...
No Matches
NZonedTime.java
1package com.vesoft.nebula.driver.graph.data;
2
3import com.vesoft.nebula.driver.graph.utils.ZoneOffsetUtil;
4import java.time.LocalTime;
5import java.time.ZoneOffset;
6import java.util.Objects;
7
8public class NZonedTime {
9
10 private final int hour;
11 private final int minute;
12 private final int second;
13 private final int microSec;
14 private final ZoneOffset timeZoneOffset;
15
16 public NZonedTime(int hour, int minute, int second, int microSec, ZoneOffset timeZoneOffset) {
17 this.hour = hour;
18 this.minute = minute;
19 this.second = second;
20 this.microSec = microSec;
21 this.timeZoneOffset = timeZoneOffset;
22 }
23
24 public NZonedTime(LocalTime localTime, ZoneOffset timeZoneOffset) {
25 this.hour = localTime.getHour();
26 this.minute = localTime.getMinute();
27 this.second = localTime.getSecond();
28 this.microSec = localTime.getNano() / 1000;
29 this.timeZoneOffset = timeZoneOffset;
30 }
31
35 public int getHour() {
36 return hour;
37 }
38
42 public int getMinute() {
43 return minute;
44 }
45
49 public int getSecond() {
50 return second;
51 }
52
56 public int getMicrosec() {
57 return microSec;
58 }
59
65 public int getOffset() {
66 return timeZoneOffset.getTotalSeconds();
67 }
68
69
70 @Override
71 public String toString() {
72 return String.format("%02d:%02d:%02d.%06d%s",
73 hour,
74 minute,
75 second,
76 microSec,
77 ZoneOffsetUtil.buildOffset(getOffset()));
78 }
79
80 @Override
81 public boolean equals(Object o) {
82 if (this == o) {
83 return true;
84 }
85 if (o == null || getClass() != o.getClass()) {
86 return false;
87 }
88 NZonedTime that = (NZonedTime) o;
89 return hour == that.getHour()
90 && minute == that.getMinute()
91 && second == that.getSecond()
92 && microSec == that.getMicrosec()
93 && getOffset() == that.getOffset();
94 }
95
96 @Override
97 public int hashCode() {
98 return Objects.hash(hour, minute, second, microSec, getOffset());
99 }
100}
int getOffset()
get zone offset in seconds