pentaho/pentaho-kettle · error · JavaScriptException
Could not apply the given format
Error message
Could not apply the given format {sArg2} on the string for {sArg1} : {e.getMessage()} What it means
Parsing failure in the 2-argument branch of str2date: the user-supplied format pattern (sArg2) could not be applied to the input string (sArg1). The generic catch rethrows with the pattern, the string, and the underlying exception message.
Solutions
- Fix the SimpleDateFormat pattern so it matches the input string layout
- Check for literal characters that need quoting in the pattern (e.g. "dd.MM.yyyy")
- Use a 3- or 4-argument call to pin the locale/timezone if defaults interfere
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:1054 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/761ba8fb4f4b062f.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:1054
// DecimalFormat formatter = new DecimalFormat();
// sRC= formatter.format(sArg1);
} catch ( Exception e ) {
throw Context.reportRuntimeError( "Could not apply local format for " + sArg1 + " : " + e.getMessage() );
}
break;
case 2:
try {
if ( isNull( ArgList, new int[] { 0, 1 } ) ) {
return null;
} else if ( isUndefined( ArgList, new int[] { 0, 1 } ) ) {
return Context.getUndefinedValue();
}
sArg1 = Context.toString( ArgList[0] );
sArg2 = Context.toString( ArgList[1] );
Format dfFormatter = new SimpleDateFormat( sArg2 );
oRC = dfFormatter.parseObject( sArg1 );
} catch ( Exception e ) {
throw Context.reportRuntimeError( "Could not apply the given format "
+ sArg2 + " on the string for " + sArg1 + " : " + e.getMessage() );
}
break;
case 3:
try {
if ( isNull( ArgList, new int[] { 0, 1, 2 } ) ) {
return null;
} else if ( isUndefined( ArgList, new int[] { 0, 1, 2 } ) ) {
return Context.getUndefinedValue();
}
sArg1 = Context.toString( ArgList[0] );
Format dfFormatter;
sArg2 = Context.toString( ArgList[1] );
sArg3 = Context.toString( ArgList[2] );
if ( sArg3.length() == 2 ) {
Locale dfLocale = EnvUtil.createLocale( sArg3 );
dfFormatter = new SimpleDateFormat( sArg2, dfLocale );
oRC = dfFormatter.parseObject( sArg1 );View on GitHub (pinned to f3058517a1)