{"record":{"id":"c8eb7962a0caf306","repo":"pentaho/pentaho-kettle","slug":"could-not-apply-local-format-for-sarg1-e-getmessage","errorCode":null,"errorMessage":"Could not apply local format for {sArg1} : {e.getMessage()}","messagePattern":"Could not apply local format for (.+?) : (.+?)","errorType":"exception","errorClass":"JavaScriptException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java","lineNumber":1039,"sourceCode":"    String sArg4 = \"\";\n    switch ( ArgList.length ) {\n      case 0:\n        throw Context.reportRuntimeError( \"Please provide a valid string to the function call str2date.\" );\n      case 1:\n        try {\n          if ( isNull( ArgList[0] ) ) {\n            return null;\n          } else if ( isUndefined( ArgList[0] ) ) {\n            return Context.getUndefinedValue();\n          }\n          sArg1 = Context.toString( ArgList[0] );\n          Format dfFormatter = new SimpleDateFormat();\n          oRC = dfFormatter.parseObject( sArg1 );\n          // if(Double.isNaN(sArg1)) throw Context.reportRuntimeError(\"The first Argument must be a Number.\");\n          // 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;","sourceCodeStart":1021,"sourceCodeEnd":1057,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java#L1021-L1057","documentation":"Parsing failure in the 1-argument branch of str2date: the input string could not be parsed with the default locale SimpleDateFormat. The generic catch wraps the underlying ParseException message, naming the offending input (sArg1).","triggerScenarios":"Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:1039 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Pass a matching format pattern as the second argument, e.g. str2date(\"31/01/2024\", \"dd/MM/yyyy\")","Verify the input string actually contains a parseable date","Add a locale and timezone if the default locale misinterprets the string"],"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"}