public static long convertDurationStrToLong(
      long currentTime, long value, String unit, String timestampPrecision) {
    DurationUnit durationUnit = DurationUnit.valueOf(unit);
    long res = value;
    switch (durationUnit) {
      case y:
      case year:
        res *= 365 * 86_400_000L;
        break;
      case mo:
      case month:
        if (currentTime == -1) {
          res *= 30 * 86_400_000L;
        } else {
          Calendar calendar = Calendar.getInstance();
          calendar.setTimeZone(SessionManager.getInstance().getSessionTimeZone());
          calendar.setTimeInMillis(currentTime);
          calendar.add(Calendar.MONTH, (int) (value));
          res = calendar.getTimeInMillis() - currentTime;
        }
        break;
      case w:
      case week:
        res *= 7 * 86_400_000L;
        break;
      case d:
      case day:
        res *= 86_400_000L;
        break;
      case h:
      case hour:
        res *= 3_600_000L;
        break;
      case m:
      case minute:
        res *= 60_000L;
        break;
      case s:
      case second:
        res *= 1_000L;
        break;
      default:
        break;
    }

    if ("us".equals(timestampPrecision) || "microsecond".equals(timestampPrecision)) {
      if (unit.equals(DurationUnit.ns.toString())
          || unit.equals(DurationUnit.nanosecond.toString())) {
        return value / 1000;
      } else if (unit.equals(DurationUnit.us.toString())
          || unit.equals(DurationUnit.microsecond.toString())) {
        return value;
      } else {
        return res * 1000;
      }
    } else if ("ns".equals(timestampPrecision) || "nanosecond".equals(timestampPrecision)) {
      if (unit.equals(DurationUnit.ns.toString())
          || unit.equals(DurationUnit.nanosecond.toString())) {
        return value;
      } else if (unit.equals(DurationUnit.us.toString())
          || unit.equals(DurationUnit.microsecond.toString())) {
        return value * 1000;
      } else {
        return res * 1000_000;
      }
    } else {
      if (unit.equals(DurationUnit.ns.toString())
          || unit.equals(DurationUnit.nanosecond.toString())) {
        return value / 1000_000;
      } else if (unit.equals(DurationUnit.us.toString())
          || unit.equals(DurationUnit.microsecond.toString())) {
        return value / 1000;
      } else {
        return res;
      }
    }
  }
convert duration string to millisecond, microsecond or nanosecond.
iotdb-core/datanode/src/main/java/org/apache/iotdb/db/utils/DateTimeUtils.java