wgtmac commented on code in PR #36519:
URL: https://github.com/apache/arrow/pull/36519#discussion_r1282614630
##########
java/flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/accessor/impl/calendar/ArrowFlightJdbcTimeStampVectorAccessor.java:
##########
@@ -149,9 +153,8 @@ protected static TimeUnit
getTimeUnitForVector(TimeStampVector vector) {
}
}
- protected static LongToLocalDateTime
getLongToLocalDateTimeForVector(TimeStampVector vector,
-
TimeZone timeZone) {
- String timeZoneID = timeZone.getID();
+ protected static LongToLocalDateTime
getLongToUTCDateTimeForVector(TimeStampVector vector) {
+ String timeZoneID = "UTC";
ArrowType.Timestamp arrowType =
(ArrowType.Timestamp) vector.getField().getFieldType().getType();
Review Comment:
In the switch block below, you may use the overload without timeZoneID,
which is much simpler:
```
DateUtility.getLocalDateTimeFromEpochNano(nanoseconds);
DateUtility.getLocalDateTimeFromEpochMicro(microseconds);
DateUtility.getLocalDateTimeFromEpochMilli(milliseconds);
DateUtility.getLocalDateTimeFromEpochMilli(TimeUnit.SECONDS.toMillis(seconds));
```
##########
java/flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/accessor/impl/calendar/ArrowFlightJdbcTimeStampVectorAccessor.java:
##########
@@ -149,9 +153,8 @@ protected static TimeUnit
getTimeUnitForVector(TimeStampVector vector) {
}
}
- protected static LongToLocalDateTime
getLongToLocalDateTimeForVector(TimeStampVector vector,
-
TimeZone timeZone) {
- String timeZoneID = timeZone.getID();
+ protected static LongToLocalDateTime
getLongToUTCDateTimeForVector(TimeStampVector vector) {
Review Comment:
It would be good if we can rename the return type `LongToLocalDateTime` as
well.
##########
java/flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/accessor/impl/calendar/ArrowFlightJdbcTimeStampVectorAccessor.java:
##########
@@ -91,14 +91,18 @@ private LocalDateTime getLocalDateTime(Calendar calendar) {
long value = holder.value;
LocalDateTime localDateTime = this.longToLocalDateTime.fromLong(value);
-
- if (calendar != null) {
- TimeZone timeZone = calendar.getTimeZone();
- long millis = this.timeUnit.toMillis(value);
- localDateTime = localDateTime
- .minus(timeZone.getOffset(millis) - this.timeZone.getOffset(millis),
ChronoUnit.MILLIS);
+ ZoneId defaultTimeZone = Calendar.getInstance().getTimeZone().toZoneId();
+ ZoneId sourceTimeZone;
+
+ if (this.timeZone != null) {
+ sourceTimeZone = this.timeZone.toZoneId();
Review Comment:
As per the comment from @lidavidm, sourceTimeZone should be UTC if the
vector has provided a valid timezone.
##########
java/flight/flight-sql-jdbc-core/src/main/java/org/apache/arrow/driver/jdbc/accessor/impl/calendar/ArrowFlightJdbcTimeStampVectorAccessor.java:
##########
@@ -177,7 +174,7 @@ protected static TimeZone
getTimeZoneForVector(TimeStampVector vector) {
String timezoneName = arrowType.getTimezone();
if (timezoneName == null) {
- return TimeZone.getTimeZone("UTC");
+ return null;
Review Comment:
+1
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]