pentaho/pentaho-kettle · error · KettleValueException
TO_DATE Couldn't convert String to Date
Error message
TO_DATE Couldn't convert String to Date
What it means
Thrown when the legacy Value str2dat/TO_DATE function's SimpleDateFormat.parse() of getString() fails. The value is reset to a null Date before rethrowing; the cause (usually unparseable text or a mismatched pattern in arg0) is appended to the message.
Solutions
- Make the TO_DATE format pattern (arg0) match the actual layout of the input string
- Clean or pre-trim the source string so it conforms to the expected date format
- Handle null/blank input before calling TO_DATE
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at core/src/main/java/org/pentaho/di/compatibility/Value.java:3168 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/7d4eee3ab9567e55.
Report an issue: GitHub.
Appendix: source
Thrown at core/src/main/java/org/pentaho/di/compatibility/Value.java:3168
SimpleDateFormat df = new SimpleDateFormat();
DateFormatSymbols dfs = new DateFormatSymbols();
if ( arg1 != null ) {
dfs.setLocalPatternChars( arg1 );
}
if ( arg0 != null ) {
df.applyPattern( arg0 );
}
try {
value.setDate( df.parse( getString() ) );
setType( VALUE_TYPE_DATE );
setLength( -1, -1 );
} catch ( Exception e ) {
setType( VALUE_TYPE_DATE );
setNull();
throw new KettleValueException( "TO_DATE Couldn't convert String to Date" + e.toString() );
}
}
return this;
}
// implement the TO_NUMBER function, arguments in args[]
public Value str2num() throws KettleValueException {
return str2num( null, null, null, null );
}
public Value str2num( String pattern ) throws KettleValueException {
return str2num( pattern, null, null, null );
}
public Value str2num( String pattern, String decimal ) throws KettleValueException {
return str2num( pattern, decimal, null, null );
}
View on GitHub (pinned to f3058517a1)