Skip to content

[Java] ArrowFlightJdbcTimeStampVectorAccessor does not deal with calendar correctly #35138

@wgtmac

Description

@wgtmac

Describe the bug, including details regarding any error messages, version, and platform.

The piece of code below in the class ArrowFlightJdbcTimeStampVectorAccessor does not deal with timezone correctly.

  private LocalDateTime getLocalDateTime(Calendar calendar) {
    getter.get(getCurrentRow(), holder);
    this.wasNull = holder.isSet == 0;
    this.wasNullConsumer.setWasNull(this.wasNull);
    if (this.wasNull) {
      return null;
    }

    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);
    }
    return localDateTime;
  }

It should call localDateTime.plus instead of localDateTime.minus.

I hit this issue when integrating this into our own JDBC implementation and found that the timestamp string in the ResultSet is wrong when converting between timezones.

Component(s)

Java

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions