Skip to content

[FE] SimpleDateFormat needs to set timezone #3829

@vagetablechicken

Description

@vagetablechicken

Describe the bug

In UT DynamicPartitionUtilTest, we set calendar timezone by TimeUtils.getDefaultTimeZone().
https://github.com/apache/incubator-doris/blob/2ce2cf78acc298a094771d1b6df602aeddb3e8d1/fe/src/test/java/org/apache/doris/common/util/DynamicPartitionUtilTest.java#L56-L62
But we parse calendar.getTime(). It's a Date, Date has no time zone. So the Date obj is back to GMT/UTC.
https://github.com/apache/incubator-doris/blob/2ce2cf78acc298a094771d1b6df602aeddb3e8d1/fe/src/main/java/org/apache/doris/common/util/DynamicPartitionUtil.java#L429-L435

So does Calendar::setTime().
https://github.com/apache/incubator-doris/blob/30b712c1584281e4831ea900154e4240e78861ff/fe/src/main/java/org/apache/doris/common/util/DynamicPartitionUtil.java#L336

To solve it, SimpleDateFormat could set the same timezone with calendar. We shouldn't relay on the current timezone of system.

To Reproduce
Steps to reproduce the behavior:

  1. set system timezone to other
  2. run fe ut DynamicPartitionUtilTest

Additional context
This issue only focuses on Calendar & SimpleDateFormat. We think calendar has its timezone, but getTime() will give the GMT/UTC time. We will use SimpleDateFormat's timezone to format it(Date obj).
Maybe there are other problems about timezone. Need more attention.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions