pentaho/pentaho-kettle · error · JavaScriptException

Locale is not 2 characters long.

Error message

Locale {sArg3} is not 2 characters long.

What it means

Locale validation in the 3-argument branch of str2date: the third argument (locale code) is not exactly two characters, so EnvUtil.createLocale cannot build a Locale for it. This guard fires before the formatter is constructed.

Solutions

  1. Pass an ISO 639 two-letter language code such as "en", "de", or "fr" as the third argument
  2. Drop the locale argument to fall back to the default locale
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:1074 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/3ddc3c4ecef6ce72. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/scriptvalues_mod/ScriptValuesAddedFunctions.java:1074

        }
        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 );
          } else {
            throw Context.reportRuntimeError( "Locale " + sArg3 + " is not 2 characters long." );
          }
        } catch ( Exception e ) {
          throw Context
            .reportRuntimeError( "Could not apply the local format for locale "
              + sArg3 + " with the given format " + sArg2 + " on the string for " + sArg1 + " : "
              + e.getMessage() );
        }
        break;
      case 4:
        try {
          if ( isNull( ArgList, new int[] { 0, 1, 2, 3 } ) ) {
            return null;
          } else if ( isUndefined( ArgList, new int[] { 0, 1, 2, 3 } ) ) {
            return Context.getUndefinedValue();
          }
          sArg1 = Context.toString( ArgList[0] );
          DateFormat dfFormatter;
          sArg2 = Context.toString( ArgList[1] );

View on GitHub (pinned to f3058517a1)