pentaho/pentaho-kettle · error · ParseException
Unknown date format. Format is null.
Error message
Unknown date format. Format is null.
What it means
DateDetector.getDateFromStringByFormat parses a date string with a caller-supplied format using a non-lenient SimpleDateFormat. If the dateFormat argument is null, a ParseException 'Unknown date format. Format is null.' is thrown immediately, because a null pattern cannot construct a formatter.
Solutions
- Null-check the format before calling; fall back to detectDateFormat or a default pattern
- Hard-code or validate the expected format string at configuration time
- Use getDateFromString (auto-detect) when format is unknown instead of passing null
Example fix
// before
Date d = DateDetector.getDateFromStringByFormat(s, maybeNullFormat);
// after
if (maybeNullFormat == null) { maybeNullFormat = DateDetector.detectDateFormat(s); }
Date d = DateDetector.getDateFromStringByFormat(s, maybeNullFormat); Defensive patterns
Strategy: validation
Validate before calling
if (dateFormat == null) { dateFormat = "yyyy-MM-dd"; } // or resolve via detectDateFormat
if (dateString == null) { throw new IllegalArgumentException("dateString required"); } Try / catch
try {
return DateDetector.getDateFromStringByFormat(s, fmt);
} catch (ParseException e) {
LOG.error("Bad format '{}' or value '{}'", fmt, s, e);
throw e;
} Prevention
- Never forward detectDateFormat results without a null check
- Load date formats from validated configuration with defaults
- Fail fast at config-load time when the format key is missing
When it happens
Trigger: Passing a null format, typically the result of detectDateFormat returning null that was forwarded without checking, or a config variable that failed to resolve.
Common situations: Chaining detectDateFormat() -> getDateFromStringByFormat() without a null check; date format read from missing properties/settings.
Related errors
- Unknown date string. Date string is null.
- Could not apply local format for
- Could not apply the given format " + sArg2 + " on the…
- TO_DATE Couldn't convert String to Date
- <toString()> : couldn't convert string
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/594b92852f2a4673.
Report an issue: GitHub.
Appendix: source
Thrown at core/src/main/java/org/pentaho/di/core/util/DateDetector.java:242
if ( dateFormat == null ) {
throw new ParseException( "Unknown date format.", 0 );
}
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)