Skip to content

Commit

Permalink
[Fix](Timezone)The time zone should not be fixed to UTC+8. (apache#37294
Browse files Browse the repository at this point in the history
)

## Proposed changes


It is generally more reasonable to use the system's default time zone
rather than binding the default time zone to UTC+8. This approach
ensures that the application will behave correctly in different
environments and regions.

**For countries that observe DST, this might require extra attention.**
  • Loading branch information
CalvinKirs authored Jul 5, 2024
1 parent 71a23d0 commit fa389f4
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,6 @@ public class TimeUtils {
public static Date MAX_DATETIME = null;

static {
TIME_ZONE = ZoneId.of("UTC+8");

Map<String, String> timeZoneMap = Maps.newHashMap();
timeZoneMap.putAll(ZoneId.SHORT_IDS);

Expand All @@ -98,7 +96,7 @@ public class TimeUtils {
timeZoneMap.put("GMT", UTC_TIME_ZONE);

timeZoneAliasMap = ImmutableMap.copyOf(timeZoneMap);

TIME_ZONE = getSystemTimeZone().toZoneId();
DATE_FORMAT = DateTimeFormatter.ofPattern("yyyy-MM-dd");
DATE_FORMAT.withZone(TIME_ZONE);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ public void testNormal() {
Assert.assertNotNull(TimeUtils.getCurrentFormatTime());
Assert.assertNotNull(TimeUtils.getStartTimeMs());
Assert.assertTrue(TimeUtils.getElapsedTimeMs(0L) > 0);

Assert.assertEquals(-62135625600000L, TimeUtils.MIN_DATE.getTime());
Assert.assertEquals(253402185600000L, TimeUtils.MAX_DATE.getTime());
Assert.assertEquals(-62135625600000L, TimeUtils.MIN_DATETIME.getTime());
Assert.assertEquals(253402271999000L, TimeUtils.MAX_DATETIME.getTime());
}

@Test
Expand Down

0 comments on commit fa389f4

Please sign in to comment.