Uploaded image for project: 'Flink'
  1. Flink
  2. FLINK-19757

TimeStampData can cause time inconsistent problem

    XMLWordPrintableJSON

Details

    Description

      when we check jdk LocalDateTime code,we find that

       

      // code placeholder
      
      
      public static LocalDateTime ofEpochSecond(long epochSecond, int nanoOfSecond, ZoneOffset offset) {
          Objects.requireNonNull(offset, "offset");
          NANO_OF_SECOND.checkValidValue(nanoOfSecond);
          long localSecond = epochSecond + offset.getTotalSeconds();  // overflow caught later
          long localEpochDay = Math.floorDiv(localSecond, SECONDS_PER_DAY);
          int secsOfDay = (int)Math.floorMod(localSecond, SECONDS_PER_DAY);
          LocalDate date = LocalDate.ofEpochDay(localEpochDay);
          LocalTime time = LocalTime.ofNanoOfDay(secsOfDay * NANOS_PER_SECOND + nanoOfSecond);
          return new LocalDateTime(date, time);
      }
      

       

      offset.getTotalSeconds() they add the offset, but in the TimeStampData

      toLocalDateTime, we don't add a offset.

       

      I'd like to add a TimeZone.getDefault().getRawOffset() in the 

      toLocalDateTime()

      and minus a TimeZone.getDefault().getRawOffset() in the 

      fromLocalDateTime

      Attachments

        Issue Links

          Activity

            People

              Unassigned Unassigned
              zhoujira86 xiaogang zhou
              Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

                Created:
                Updated:
                Resolved: