{"record":{"id":"761ba8fb4f4b062f","repo":"pentaho/pentaho-kettle","slug":"could-not-apply-the-given-format-sarg2-on-the-string-for-761ba8","errorCode":null,"errorMessage":"Could not apply the given format {sArg2} on the string for {sArg1} : {e.getMessage()}","messagePattern":"Could not apply the given format (.+?) on the string for (.+?) : (.+?)","errorType":"exception","errorClass":"JavaScriptException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java","lineNumber":1054,"sourceCode":"          // DecimalFormat formatter = new DecimalFormat();\n          // sRC= formatter.format(sArg1);\n        } catch ( Exception e ) {\n          throw Context.reportRuntimeError( \"Could not apply local format for \" + sArg1 + \" : \" + e.getMessage() );\n        }\n        break;\n      case 2:\n        try {\n          if ( isNull( ArgList, new int[] { 0, 1 } ) ) {\n            return null;\n          } else if ( isUndefined( ArgList, new int[] { 0, 1 } ) ) {\n            return Context.getUndefinedValue();\n          }\n          sArg1 = Context.toString( ArgList[0] );\n          sArg2 = Context.toString( ArgList[1] );\n          Format dfFormatter = new SimpleDateFormat( sArg2 );\n          oRC = dfFormatter.parseObject( sArg1 );\n        } catch ( Exception e ) {\n          throw Context.reportRuntimeError( \"Could not apply the given format \"\n            + sArg2 + \" on the string for \" + sArg1 + \" : \" + e.getMessage() );\n        }\n        break;\n      case 3:\n        try {\n          if ( isNull( ArgList, new int[] { 0, 1, 2 } ) ) {\n            return null;\n          } else if ( isUndefined( ArgList, new int[] { 0, 1, 2 } ) ) {\n            return Context.getUndefinedValue();\n          }\n          sArg1 = Context.toString( ArgList[0] );\n          Format dfFormatter;\n          sArg2 = Context.toString( ArgList[1] );\n          sArg3 = Context.toString( ArgList[2] );\n          if ( sArg3.length() == 2 ) {\n            Locale dfLocale = EnvUtil.createLocale( sArg3 );\n            dfFormatter = new SimpleDateFormat( sArg2, dfLocale );\n            oRC = dfFormatter.parseObject( sArg1 );","sourceCodeStart":1036,"sourceCodeEnd":1072,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java#L1036-L1072","documentation":"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.","triggerScenarios":"Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:1054 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}