docs: public synchronized Object convertToDatetimeInterval(String s,
              DTIType type) {
  
          Object       value;
          IntervalType intervalType  = null;
          int          dateTimeToken = -1;
          int          errorCode     = type.isDateTimeType() ? ErrorCode.X_22007
                                                             : ErrorCode.X_22006;
  
          reset(s);
          resetState();
          scanToken();
          scanWhitespace();
  
          switch (token.tokenType) {
  
              case Tokens.INTERVAL :
              case Tokens.DATE :
              case Tokens.TIME :
              case Tokens.TIMESTAMP :
                  dateTimeToken = token.tokenType;
  
                  scanToken();
  
                  if (token.tokenType != Tokens.X_VALUE
                          || token.dataType.typeCode != Types.SQL_CHAR) {
  
                      // error datetime bad literal
                      throw Error.error(errorCode);
                  }
  
                  s = token.tokenString;
  
                  scanNext(ErrorCode.X_22007);
  
                  if (type.isIntervalType()) {
                      intervalType = scanIntervalType();
                  }
  
                  if (token.tokenType != Tokens.X_ENDPARSE) {
                      throw Error.error(errorCode);
                  }
  
              // $FALL-THROUGH$
              default :
          }
  
          switch (type.typeCode) {
  
              case Types.SQL_DATE :
                  if (dateTimeToken != -1 && dateTimeToken != Tokens.DATE) {
                      throw Error.error(errorCode);
                  }
  
                  return newDate(s);
  
              case Types.SQL_TIME :
              case Types.SQL_TIME_WITH_TIME_ZONE : {
                  if (dateTimeToken != -1 && dateTimeToken != Tokens.TIME) {
                      throw Error.error(errorCode);
                  }
  
                  return newTime(s);
              }
              case Types.SQL_TIMESTAMP :
              case Types.SQL_TIMESTAMP_WITH_TIME_ZONE : {
                  if (dateTimeToken != -1 && dateTimeToken != Tokens.TIMESTAMP) {
                      throw Error.error(errorCode);
                  }
  
                  return newTimestamp(s);
              }
              default :
                  if (dateTimeToken != -1 && dateTimeToken != Tokens.INTERVAL) {
                      throw Error.error(errorCode);
                  }
  
                  if (type.isIntervalType()) {
                      value = newInterval(s, (IntervalType) type);
  
                      if (intervalType != null) {
                          if (intervalType.startIntervalType != type
                                  .startIntervalType || intervalType
                                  .endIntervalType != type.endIntervalType) {
                              throw Error.error(errorCode);
                          }
                      }
  
                      return value;
                  }
  
                  throw Error.runtimeError(ErrorCode.U_S0500, "Scanner");
          }
      }