public static Integer parseTime()

in amoro-format-mixed/amoro-mixed-flink/amoro-mixed-flink-common/src/main/java/org/apache/amoro/flink/util/DateTimeUtils.java [542:631]


  public static Integer parseTime(String v) {
    final int start = 0;
    final int colon1 = v.indexOf(':', start);
    // timezone hh:mm:ss[.ssssss][[+|-]hh:mm:ss]
    // refer https://www.w3.org/TR/NOTE-datetime
    int timezoneHour;
    int timezoneMinute;
    int hour;
    int minute;
    int second;
    int milli;
    int operator = -1;
    int end = v.length();
    int timezone = v.indexOf('-', start);
    if (timezone < 0) {
      timezone = v.indexOf('+', start);
      operator = 1;
    }
    if (timezone < 0) {
      timezoneHour = 0;
      timezoneMinute = 0;
    } else {
      end = timezone;
      final int colon3 = v.indexOf(':', timezone);
      if (colon3 < 0) {
        if (!isInteger(v.substring(timezone + 1).trim())) {
          return null;
        }
        timezoneHour = Integer.parseInt(v.substring(timezone + 1).trim());
        timezoneMinute = 0;
      } else {
        if (!isInteger(v.substring(timezone + 1, colon3).trim())) {
          return null;
        }
        timezoneHour = Integer.parseInt(v.substring(timezone + 1, colon3).trim());
        if (!isInteger(v.substring(colon3 + 1).trim())) {
          return null;
        }
        timezoneMinute = Integer.parseInt(v.substring(colon3 + 1).trim());
      }
    }
    if (colon1 < 0) {
      if (!isInteger(v.substring(start, end).trim())) {
        return null;
      }
      hour = Integer.parseInt(v.substring(start, end).trim());
      minute = 0;
      second = 0;
      milli = 0;
    } else {
      if (!isInteger(v.substring(start, colon1).trim())) {
        return null;
      }
      hour = Integer.parseInt(v.substring(start, colon1).trim());
      final int colon2 = v.indexOf(':', colon1 + 1);
      if (colon2 < 0) {
        if (!isInteger(v.substring(colon1 + 1, end).trim())) {
          return null;
        }
        minute = Integer.parseInt(v.substring(colon1 + 1, end).trim());
        second = 0;
        milli = 0;
      } else {
        if (!isInteger(v.substring(colon1 + 1, colon2).trim())) {
          return null;
        }
        minute = Integer.parseInt(v.substring(colon1 + 1, colon2).trim());
        int dot = v.indexOf('.', colon2);
        if (dot < 0) {
          if (!isInteger(v.substring(colon2 + 1, end).trim())) {
            return null;
          }
          second = Integer.parseInt(v.substring(colon2 + 1, end).trim());
          milli = 0;
        } else {
          if (!isInteger(v.substring(colon2 + 1, dot).trim())) {
            return null;
          }
          second = Integer.parseInt(v.substring(colon2 + 1, dot).trim());
          milli = parseFraction(v.substring(dot + 1, end).trim());
        }
      }
    }
    hour += operator * timezoneHour;
    minute += operator * timezoneMinute;
    return hour * (int) MILLIS_PER_HOUR
        + minute * (int) MILLIS_PER_MINUTE
        + second * (int) MILLIS_PER_SECOND
        + milli;
  }