public static long convertDurationStrToLong(
      long currentTime, String duration, String timestampPrecision, boolean convertYearToMonth) {
    long total = 0;
    long temp = 0;
    for (int i = 0; i < duration.length(); i++) {
      char ch = duration.charAt(i);
      if (Character.isDigit(ch)) {
        temp *= 10;
        temp += (ch - '0');
      } else {
        String unit = String.valueOf(duration.charAt(i));
        // This is to identify units with two letters.
        if (i + 1 < duration.length() && !Character.isDigit(duration.charAt(i + 1))) {
          i++;
          unit += duration.charAt(i);
        }
        unit = unit.toLowerCase();
        if (convertYearToMonth && unit.equals("y")) {
          temp *= 12;
          unit = "mo";
        }
        total +=
            DateTimeUtils.convertDurationStrToLong(
                currentTime == -1 ? -1 : currentTime + total, temp, unit, timestampPrecision);
        temp = 0;
      }
    }
    return total;
  }
convert duration string to time value.

@param duration represent duration string like: 12d8m9ns, 1y1mo, etc.
@param convertYearToMonth if we need convert year to month. eg: 1y -> 12mo
@return time in milliseconds, microseconds, or nanoseconds depending on the profile
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/DateTimeUtils.java