{"record":{"id":"e9852fa9590bdd37","repo":"pentaho/pentaho-kettle","slug":"the-function-call-str2date-requires-1-2-3-or-4-arguments-e9852f","errorCode":null,"errorMessage":"The function call str2date requires 1, 2, 3, or 4 arguments.","messagePattern":"The function call str2date requires 1, 2, 3, or 4 arguments\\.","errorType":"exception","errorClass":"JavaScriptException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java","lineNumber":1116,"sourceCode":"          TimeZone tz = TimeZone.getTimeZone( sArg4 );\n\n          if ( sArg3.length() == 2 ) {\n            Locale dfLocale = EnvUtil.createLocale( sArg3 );\n            dfFormatter = new SimpleDateFormat( sArg2, dfLocale );\n            dfFormatter.setTimeZone( tz );\n            oRC = dfFormatter.parseObject( sArg1 );\n          } else {\n            throw Context.reportRuntimeError( \"Locale \" + sArg3 + \" is not 2 characters long.\" );\n          }\n        } catch ( Exception e ) {\n          throw Context\n            .reportRuntimeError( \"Could not apply the local format for locale \"\n              + sArg3 + \" with the given format \" + sArg2 + \" on the string for \" + sArg1 + \" : \"\n              + e.getMessage() );\n        }\n        break;\n      default:\n        throw Context.reportRuntimeError( \"The function call str2date requires 1, 2, 3, or 4 arguments.\" );\n    }\n    return oRC;\n  }\n\n  public static Object date2str( Context actualContext, Scriptable actualObject, Object[] ArgList,\n    Function FunctionContext ) {\n    Object oRC = new Object();\n    switch ( ArgList.length ) {\n      case 0:\n        throw Context.reportRuntimeError( \"Please provide a valid date to the function call date2str.\" );\n      case 1:\n        try {\n          if ( isNull( ArgList ) ) {\n            return null;\n          } else if ( isUndefined( ArgList ) ) {\n            return Context.getUndefinedValue();\n          }\n          java.util.Date dArg1 = (java.util.Date) Context.jsToJava( ArgList[0], java.util.Date.class );","sourceCodeStart":1098,"sourceCodeEnd":1134,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java#L1098-L1134","documentation":"Arity guard at the default branch of str2date's argument-count switch: the call used more than 4 arguments. Only 1 (string), 2 (+format), 3 (+locale), and 4 (+timezone) forms are supported; anything else falls through to this throw.","triggerScenarios":"Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:1116 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reduce the call to at most four arguments: string, format, locale, timezone"],"exampleFix":null,"handlingStrategy":"validation","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"}