NebulaGraph Java Client 5.0.0
Loading...
Searching...
No Matches
NDateTime.java
1package com.vesoft.nebula.driver.graph.data;
2
3
4import com.vesoft.nebula.proto.common.LocalDatetime;
5import java.util.Objects;
6
7public class NDateTime {
8 private final LocalDatetime localDateTime;
9
10 public NDateTime(LocalDatetime localDateTime) {
11 this.localDateTime = localDateTime;
12 }
13
17 public int getYear() {
18 return localDateTime.getYear();
19 }
20
24 public int getMonth() {
25 return localDateTime.getMonth();
26 }
27
31 public int getDay() {
32 return localDateTime.getDay();
33 }
34
38 public int getHour() {
39 return localDateTime.getHour();
40 }
41
45 public int getMinute() {
46 return localDateTime.getMinute();
47 }
48
52 public int getSecond() {
53 return localDateTime.getSec();
54 }
55
59 public int getMicrosec() {
60 return localDateTime.getMicrosec();
61 }
62
63 @Override
64 public String toString() {
65 return String.format("%d-%02d-%02dT%02d:%02d:%02d.%06d",
66 localDateTime.getYear(), localDateTime.getMonth(), localDateTime.getDay(),
67 localDateTime.getHour(), localDateTime.getMinute(), localDateTime.getSec(),
68 localDateTime.getMicrosec());
69 }
70
71 @Override
72 public boolean equals(Object o) {
73 if (this == o) {
74 return true;
75 }
76 if (o == null || getClass() != o.getClass()) {
77 return false;
78 }
79 NDateTime that = (NDateTime) o;
80 return localDateTime.getYear() == that.getYear()
81 && localDateTime.getMonth() == that.getMonth()
82 && localDateTime.getDay() == that.getDay()
83 && localDateTime.getHour() == that.getHour()
84 && localDateTime.getMinute() == that.getMinute()
85 && localDateTime.getSec() == that.getSecond()
86 && localDateTime.getMicrosec() == that.getMicrosec();
87 }
88
89 @Override
90 public int hashCode() {
91 return Objects.hash(localDateTime);
92 }
93}