pentaho/pentaho-kettle · error · ParseException

Unknown date string. Date string is null.

Error message

Unknown date string. Date string is null. 

What it means

DateDetector.getDateFromStringByFormat also validates the date string itself: if dateString is null, a ParseException 'Unknown date string. Date string is null.' is thrown. The non-lenient parser would otherwise NPE or misbehave, so this gives an explicit, checkable error.

Solutions

  1. Null-check the input string before parsing and skip/default the field
  2. Treat empty strings as null and handle explicitly before conversion
  3. Coalesce with a default date when the field is legitimately optional

Example fix

// before
Date d = DateDetector.getDateFromStringByFormat(row.getString("dt"), fmt);
// after
String s = row.getString("dt");
Date d = (s == null || s.isEmpty()) ? null : DateDetector.getDateFromStringByFormat(s, fmt);
Defensive patterns

Strategy: validation

Validate before calling

if (dateString == null || dateString.trim().isEmpty()) { return null; /* optional field */ }

Type guard

static boolean isPresent(String s) { return s != null && !s.trim().isEmpty(); }

Try / catch

try {
  return DateDetector.getDateFromStringByFormat(s, fmt);
} catch (ParseException e) {
  if (s == null) return null; // treat as missing
  throw e;
}

Prevention

When it happens

Trigger: Calling getDateFromStringByFormat(null, format), e.g. when the upstream field was absent in a row, a CSV column was missing, or a variable did not resolve.

Common situations: Optional date columns in input files; rows with empty/missing fields reaching date conversion; unresolvable Kettle environment variables.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/c98001ac611d6ba9. Report an issue: GitHub.

Appendix: source

Thrown at core/src/main/java/org/pentaho/di/core/util/DateDetector.java:245

    return getDateFromStringByFormat( dateString, dateFormat );
  }

  /**
   * 
   * @param dateString
   *          date string for parse
   * @param dateFormat
   *          format which should be applied for string
   * @return {@link java.util.Date} converted from dateString by format
   * @throws ParseException
   *           if we can not parse date string
   */
  public static Date getDateFromStringByFormat( String dateString, String dateFormat ) throws ParseException {
    if ( dateFormat == null ) {
      throw new ParseException( "Unknown date format. Format is null. ", 0 );
    }
    if ( dateString == null ) {
      throw new ParseException( "Unknown date string. Date string is null. ", 0 );
    }
    SimpleDateFormat simpleDateFormat = new SimpleDateFormat( dateFormat );
    simpleDateFormat.setLenient( false ); // Don't automatically convert invalid date.
    return simpleDateFormat.parse( dateString );
  }

  /**
   * 
   * @param dateString
   *          - date string for detect date format
   * @return {@link java.lang.String} string which represented Date Format or null
   * 
   */
  public static String detectDateFormat( String dateString ) {
    return detectDateFormat( dateString, null );
  }

  /**

View on GitHub (pinned to f3058517a1)