1010import java .time .LocalDateTime ;
1111import java .time .LocalTime ;
1212import java .time .OffsetDateTime ;
13- import java .time .ZoneOffset ;
1413import java .time .ZonedDateTime ;
1514import java .time .format .DateTimeFormatter ;
1615import java .util .TimeZone ;
@@ -126,40 +125,41 @@ public ClickHouseDateTimeValue copy(boolean deep) {
126125
127126 @ Override
128127 public byte asByte () {
129- return isNullOrEmpty () ? (byte ) 0 : (byte ) getValue ().toEpochSecond ( ZoneOffset . UTC );
128+ return isNullOrEmpty () ? (byte ) 0 : (byte ) getValue ().atZone ( tz . toZoneId ()). toEpochSecond ( );
130129 }
131130
132131 @ Override
133132 public short asShort () {
134- return isNullOrEmpty () ? (short ) 0 : (short ) getValue ().toEpochSecond ( ZoneOffset . UTC );
133+ return isNullOrEmpty () ? (short ) 0 : (short ) getValue ().atZone ( tz . toZoneId ()). toEpochSecond ( );
135134 }
136135
137136 @ Override
138137 public int asInteger () {
139- return isNullOrEmpty () ? 0 : (int ) getValue ().toEpochSecond ( ZoneOffset . UTC );
138+ return isNullOrEmpty () ? 0 : (int ) getValue ().atZone ( tz . toZoneId ()). toEpochSecond ( );
140139 }
141140
142141 @ Override
143142 public long asLong () {
144- return isNullOrEmpty () ? 0L : getValue ().toEpochSecond ( ZoneOffset . UTC );
143+ return isNullOrEmpty () ? 0L : getValue ().atZone ( tz . toZoneId ()). toEpochSecond ( );
145144 }
146145
147146 @ Override
148147 public float asFloat () {
149148 return isNullOrEmpty () ? 0F
150- : getValue ().toEpochSecond (ZoneOffset .UTC ) + getValue ().getNano () / ClickHouseValues .NANOS .floatValue ();
149+ : getValue ().atZone (tz .toZoneId ()).toEpochSecond ()
150+ + getValue ().getNano () / ClickHouseValues .NANOS .floatValue ();
151151 }
152152
153153 @ Override
154154 public double asDouble () {
155155 return isNullOrEmpty () ? 0D
156- : getValue ().toEpochSecond ( ZoneOffset . UTC )
156+ : getValue ().atZone ( tz . toZoneId ()). toEpochSecond ( )
157157 + getValue ().getNano () / ClickHouseValues .NANOS .doubleValue ();
158158 }
159159
160160 @ Override
161161 public BigInteger asBigInteger () {
162- return isNullOrEmpty () ? null : BigInteger .valueOf (getValue ().toEpochSecond ( ZoneOffset . UTC ));
162+ return isNullOrEmpty () ? null : BigInteger .valueOf (getValue ().atZone ( tz . toZoneId ()). toEpochSecond ( ));
163163 }
164164
165165 @ Override
@@ -168,7 +168,7 @@ public BigDecimal asBigDecimal(int scale) {
168168 BigDecimal v = null ;
169169 if (value != null ) {
170170 int nanoSeconds = value .getNano ();
171- v = new BigDecimal (BigInteger .valueOf (value .toEpochSecond ( ZoneOffset . UTC )), scale );
171+ v = new BigDecimal (BigInteger .valueOf (value .atZone ( tz . toZoneId ()). toEpochSecond ( )), scale );
172172 if (scale != 0 && nanoSeconds != 0 ) {
173173 v = v .add (BigDecimal .valueOf (nanoSeconds ).divide (ClickHouseValues .NANOS ).setScale (scale ,
174174 RoundingMode .HALF_UP ));
0 commit comments