Skip to content

Conversation

@sakthivelmanii
Copy link
Contributor

UTC conversion issue:

Example date: 2018-03-25 01:00:00 UTC(or 2018-03-25 03:00:00+02:00)

Conversion to UTC

Original Epoch: 1 AM UTC (1521939600000) or 3 AM (Paris Time)
Calculated Offset: 2 hours ( 1 hr Raw Offset + 1 hr DST)
Offset Epoch: 11 PM UTC (1521932400000)

UTC to actual time

Original Epoch: 11 PM UTC (1521932400000 )
Calculated Offset: 1 hr ( 1hr Raw offset)
Timezone converted Epoch: 12 AM UTC(1521936000000)

We are losing 1hr because of DST. In order to solve this issue, we are adding timezone raw offset and DST savings so that it will handle the edge case when timestamp is start of DST.

Offset is purely computed on two fields. Raw offset and if time is within DST, then DST offset.

@sakthivelmanii sakthivelmanii requested a review from a team as a code owner October 21, 2025 13:57
@product-auto-label product-auto-label bot added size: s Pull request size is small. api: spanner Issues related to the googleapis/java-spanner-jdbc API. labels Oct 21, 2025
@sakthivelmanii sakthivelmanii marked this pull request as draft October 21, 2025 14:27
rahul2393
rahul2393 previously approved these changes Oct 21, 2025
@sakthivelmanii sakthivelmanii marked this pull request as ready for review October 21, 2025 14:55
olavloite
olavloite previously approved these changes Oct 22, 2025
assertThat(actual).isEqualTo(expected.withZoneSameInstant(timeZone.toZoneId()));
});

TimeZone.setDefault(TimeZone.getDefault());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: does this do anything? It seems to set the default to the current default

@sakthivelmanii sakthivelmanii changed the title fix: Fix DST issue on UTC conversion fix: Fix UTC<->Timezone conversion issue for DST start and end timestamp Oct 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api: spanner Issues related to the googleapis/java-spanner-jdbc API. size: s Pull request size is small.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants