/**
   * @param input the input date with the date-time info
   * @param format the format of date-time info
   * @param functionName one of [TO_DATE, TO_TIMESTAMP] (both share the same code)
   */
  private ToDateParser(ConfigParam functionName, String input, String format) {
    // reset calendar - default oracle behaviour
    resultCalendar.set(Calendar.YEAR, 1970);
    resultCalendar.set(Calendar.MONTH, Calendar.getInstance().get(Calendar.MONTH));
    resultCalendar.clear(Calendar.DAY_OF_YEAR);
    resultCalendar.clear(Calendar.DAY_OF_WEEK);
    resultCalendar.clear(Calendar.DAY_OF_WEEK_IN_MONTH);
    resultCalendar.set(Calendar.DAY_OF_MONTH, 1);
    resultCalendar.set(Calendar.HOUR, 0);
    resultCalendar.set(Calendar.HOUR_OF_DAY, 0);
    resultCalendar.set(Calendar.MINUTE, 0);
    resultCalendar.set(Calendar.SECOND, 0);
    resultCalendar.set(Calendar.MILLISECOND, 0);
    resultCalendar.set(Calendar.AM_PM, Calendar.AM);

    this.functionName = functionName;
    inputStr = input.trim();
    // Keep a copy
    unmodifiedInputStr = inputStr;
    if (format == null || format.isEmpty()) {
      // default Oracle format.
      formatStr = functionName.getDefaultFormatStr();
    } else {
      formatStr = format.trim();
    }
    // Keep a copy
    unmodifiedFormatStr = formatStr;
  }
  @Override
  public String toString() {
    int inputStrLen = inputStr.length();
    int orgInputLen = unmodifiedInputStr.length();
    int currentInputPos = orgInputLen - inputStrLen;
    int restInputLen = inputStrLen <= 0 ? inputStrLen : inputStrLen - 1;

    int orgFormatLen = unmodifiedFormatStr.length();
    int currentFormatPos = orgFormatLen - formatStr.length();

    StringBuilder sb = new StringBuilder();
    sb.append(
        format("\n    %s('%s', '%s')", functionName, unmodifiedInputStr, unmodifiedFormatStr));
    sb.append(
        format(
            "\n      %s^%s ,  %s^ <-- Parsing failed at this point",
            format("%" + (functionName.name().length() + currentInputPos) + "s", ""),
            restInputLen <= 0 ? "" : format("%" + restInputLen + "s", ""),
            currentFormatPos <= 0 ? "" : format("%" + currentFormatPos + "s", "")));

    return sb.toString();
  }
 String getFunctionName() {
   return functionName.name();
 }