Skip to main content

Back End Scripting

v3.12.0+

Introduction

Scripting can be used in various places like a Script Task of a process or a Script Task of a case as well as within a service registry definition using script.

A JSR-223 compliant scripting language like JavaScript or Groovy can be used for the script itself and Flowable exposes a scripting API into the scripting context as well where you will have access to various utilities as well as to create JSON objects and get access to services, request input variables and register output parameters, depending on your context of course.

This documentation is all about the Flowable scripting API, which is exposed using flw.

Input and Output

In a script you can get input values using flw.getInput(name), depending on the context, the variable with the requested name is returned or an input parameter with that name, respectively.

The same works with flw.setOutput(name, value) where a variable value can be set or an output parameter value can be registered.

The following methods are available:

  • flw.getInput(name) depending on the context, the variable with the requested name is returned or an input parameter with that name, respectively.
  • flw.setOutput(name, value) variable value is set or an output parameter value can is registered.
  • flw.setTransientOutput(name, value) transient variable value is set.
  • flw.setLocalOutput(name, value) a variable value is set to the local scope.

Examples for a script task:

  • flw.getInput('foo'); will return the variable named foo.
  • flw.setOutput('bar', myBarValue); will store a new variable named bar with the value provided by the local scripting-variable named myBarValue.

Examples for a registry service with scripting:

  • flw.getInput('foo'); will return the mapped input parameter named foo.
  • flw.setOutput('bar', myBarValue); will register the value provided by the local scripting variable myBarValue as the output parameter named bar.

BPMN Errors

The Scripting API supports throwing BPMN Errors using the following methods:

  • flw.bpmn.throwError('ERROR_CODE')
  • flw.bpmn.throwError('ERROR_CODE', 'Error Message')

BPMN Errors can be handled using error boundary events or error event subprocesses in BPMN models, which make them a powerful tool for model based error handling, without java code modifications.

The util methods are a convenient equivalent of throw new org.flowable.engine.delegate.BpmnError('ERROR_CODE').

JSON Utilities

The scripting API also supports various utilities around JSON object handling like creating a JSON object or array or converting a JSON string into a JSON object structure.

You can access those utilities through flw.json.

To create a new, empty JSON object, use flw.json.createObject(); and store the result as a local variable or use the fluent API of the returned JSON object to create its value.

Json Objects with Simple Values

A simple Json object using just values, but without nested or list values, can be created as follows:

Examples:

var myJson = flw.json.createObject();
myJson.putString('name', 'Sample Json object');
myJson.putInteger('sum', 100);
myJson.putBoolean('verified', true);

This example could also be written as:

var myJson = flw.json.createObject()
.putString('name', 'Sample Json object')
.putInteger('sum', 100)
.putBoolean('verified', true);

Or, if used as an output value:

flw.setOutput('myJsonOutputParameter', flw.json.createObject()
.putString('name', 'Sample Json object')
.putInteger('sum', 100)
.putBoolean('verified', true));
Script variables, JSON and Flowable Variables

There are different ways to represent data with scripts:

  1. Groovy/JavaScript variables (in the following focused on JavaScript for simplification)
  2. JSON
  3. Flowable variables

In JavaScript you can create object structure and add different elements to those objects, including for example dates. E.g.: {name: 'Sample Json object', myDate: new Date()}

Converting this to JSON will then result in something like the following: {"test":"2024-01-17T05:53:01.880Z"}. This can be assigned in JavaScript to a variable, however it still does not make every JavaScript variable a valid JSON. E.g. {test: () => { return 'test' }} will be a valid object in JavaScript, but converting it to JSON results in an empty object {}.

The Flowable flw.json API is language agnostic across different scripting languages with backwards compatibility. The JavaScript execution comes from the Nashorn engine and might differ between different Java version and/or versions of the Nashorn engine available on the classpath.

It is also possible to create a JSON structure directly with JavaScript/Groovy, just be aware that this depends on the execution engine.

The following example would use the JavaScript engine to create an object, convert it to a JSON and then add it as the Flowable JSON variable testJson:

flw.setOutput("testJson",
flw.json.stringToJson(
JSON.stringify({name: 'Sample Json object', test: new Date()})
)
);

Nested Json Objects

Nested objects can also be created easily:

var myJson = flw.json.createObject()
.putString('name', 'Sample Json object');

myJson.createChildObject('nestedObject')
.putString('nestedObjectName', 'Nested Json object');
note

The method createChildObject will create a new child Json object and add it to the current object (where the method is invoked from) using the provided field name.
Pay attention to the return values; createObject() will return the root Json object, but createChildObject always just returns the newly created child object for further processing like adding values. If you need to eventually use the root object, make sure to keep a variable with the returned root Json object and not just the latest nested one.

Json Arrays

A Json array can either be created as a 'root' Json object or as a nested one.

Creating just a Json array, can be done using the createArray method of the json utility:

var myJsonArray = flw.json.createArray()
.addString('hello')
.addString('world');

Creating a nested Json array is simple as well:

var myJson = flw.json.createObject()
.putString('name', 'Sample Json object');

myJson.createChildArray('nestedList')
.addString('hello')
.addString('world');
note

To add values to an array, make use of the addXY methods, not the putXY ones which are used to set a value to a Json object.

Available Methods

The following section lists available methods for Json objects created with flw.json.createObject, flw.json.createArray or flw.json.stringToJson.

Common Methods

This is a list of available common methods:

  • size() The number of attributes for this object or array length.
  • isArray() returns true, when the node is an array node.
  • isObject() returns true, when the node is an object node.
  • isValue() returns true, when the node is a value node.
  • isPresent() returns true, when the node is present.
  • isNonNull() returns true, when the node is present and not null.
  • iterator() returns an iterator to iterate array elements. For an object node a single element iterator with the object itself is returned.

Object Methods

This is a list of available methods for a Json object (not an array):

  • putString(fieldName, value) with a String value.
  • putInteger(fieldName, value) with a Number value.
  • putInt(fieldName, value) with an int value.
  • putBoolean(fieldName, value) with a boolean value.
  • putShort(fieldName, value) with a Number or a short.
  • putLong(fieldName, value) with a Number or a long .
  • putDouble(fieldName, value) with a Number or a double.
  • putFloat(fieldName, value) with a Number or a float.
  • putObject(fieldName, value) adds an object. The object can either be null (then putNull is used instead) or another Json object or array.
  • putNull(fieldName) adds a null value to an object.
  • createChildObject(fieldName) creates a new child Json object and add it as a nested object to the current one.
  • createChildArray(fieldName) creates a new Json array and add it as a child array to the current one.
  • path(path) returns the Json node for the given path. When the path does not exist the resulting object returns false for isPresent().
  • fieldNames() returns a collection of all field names of the object node. Empty collection in case the node ist not an object.

Array Methods

This is a list of available methods for a Json array (not an object):

  • addString(value) with a String value.
  • addInteger(value) with a Number value.
  • addInt(value) with an int value.
  • addBoolean(value) with a boolean value.
  • addShort(value) with a Number or a short value.
  • addLong(value) with a Number or a long value.
  • addDouble(value) with a Number or a double value.
  • addFloat(value) with a Number a float value.
  • addNull() to add a null value to the array.
  • addObject(value) adds an object to the array. The object can either be null or another Json object or array.
  • path(index) will return the element at the provided index. When the index does not exist the resulting object returns false for isPresent().

Value Methods

This is a list of available methods for values. All methods throw a FlowableException in case they are called on non-values or null nodes.

  • asString() returns the given value node as string. Converts non string values to its string representation.
  • asInteger() returns a numeric value as integer. FlowableException thrown in case it is not an integral number or in case of integer overflows.
  • asLong() returns a numeric value as long. FlowableException thrown in case it is not an integral number.
  • asDouble() returns a numeric value as double.
  • asBoolean() returns a boolean value. Does not coerce other value types into boolean.
  • isString() returns true, when the node is a string.
  • isNumber() returns true, when the node is a number.
  • isBoolean() returns true, when the node is a boolean.

Json String Conversion

If you have a string representing a Json object, you can convert it into a Json object for further processing and back to string, if required.

  • flw.json.stringToJson
  • flw.json.jsonToString

Example:

var myJsonString = '{ "foo": "fooValue", "bar": "barValue", "sum": 100, "verified": true }';
var myJson = flw.json.stringToJson(myJsonString);
myJson.putString("my_value", "value");
var string = flw.json.jsonToString(myJson);

Time Utilities

The scripting API also supports utilities around date and time handling, which is accessible through flw.time.
If not mentioned differently, default time zone is always UTC.

You can use the same functionality as with an expression using flwTimeUtils.

Here is a list of available functions:

FunctionDescription
Instant now()Returns the current date and time in UTC.
Instant currentDate()Returns the current date at 00:00 AM UTC as an Instant.
LocalDate currentLocalDate()Returns the current date in the system time zone (which is UTC) as a LocalDate instance.
LocalDateTime currentLocalDateTime()Returns the current date and time in the system time zone (which is UTC) as a LocalDateTime instance.
Instant instantFromTimestamp(long timestamp)Returns an Instant from the number of seconds that have passed since the first of January 1970 (Unix Timestamp).
Date dateFromTimestamp(long timestamp)Returns an Date from the number of seconds that have passed since the first of January 1970 (Unix Timestamp).
Instant parseInstant(Date date)Returns an Instant out of a Date
Instant parseInstant(String instantIsoString)Parses an ISO8601 formatted string into an Instant.
Instant parseInstant(Object value, String pattern)Parses an object into an Instant using the provided pattern. Supported inputs are String, Json TextNode or null.
LocalDate parseLocalDate(Object value, String pattern)Parses an object into a LocalDate using the provided pattern. Supported inputs are String, Json TextNode or null.
LocalDateTime parseLocalDateTime(Object value, String pattern)Parses an object into a LocalDateTime using the provided pattern. Supported inputs are String, Json TextNode or null.
Instant asInstant(Object value)Converts a value to an Instant with UTC time zone. Supported values are: Date, Instant (which will be returned directly), LocalDate, LocalDateTime, an ISO8601 formatted String or null.
Instant asInstant(Object value, String timeZoneId)Converts a value to an Instant in the given time zone. Supported values are: Date, Instant (which will be returned directly), LocalDate, LocalDateTime, an ISO8601 formatted String or null.
LocalDate asLocalDate(Object value)Converts a value to a LocalDate with UTC time zone. Supported values are: Date, Instant, LocalDate (which will be returned directly), LocalDateTime, an ISO8601 formatted String or null.
LocalDate asLocalDate(Object value, String timeZoneId)Converts a value to an LocalDate in the given time zone. Supported values are: Date, Instant, LocalDate (which will be returned directly), LocalDateTime, an ISO8601 formatted String or null.
LocalDateTime asLocalDateTime(Object value)Converts a value to a LocalDateTime with UTC time zone. Supported values are: Date, Instant, LocalDate, LocalDateTime (which will be returned directly), an ISO8601 formatted String or null.
LocalDateTime asLocalDateTime(Object value, String timeZoneId)Converts a value to an LocalDateTime in the given time zone. Supported values are: Date, Instant, LocalDate, LocalDateTime (which will be returned directly), an ISO8601 formatted String or null.
Date asDate(Object value)Converts a value to a Date in the UTC time zone. Supported values are Instant, LocalDate, LocalDateTime, an ISO8601 formatted String or null.
Object atTime(Object value, int hours, int minutes, int seconds)Sets the time of the value to the specified hours, minutes and seconds in the UTC time zone. Supported values are Date, Instant, LocalDateTime or an ISO8601 formatted String. The returned value will be the same type as the input type, for a string, it will either be an Instant or a LocalDateTime depending on the provided format of the string.
Object atTimeWithTimeZone(Object value, int hours, int minutes, int seconds, String timeZoneId)Sets the time of the value to the specified hours, minutes and seconds in the given time zone. Supported values are Date, Instant, LocalDateTime or an ISO8601 formatted String. The returned value will be the same type as the input type, for a string, it will either be an Instant or a LocalDateTime depending on the provided format of the string.
Object atTimeZone(Object value, String timeZoneId)Returns an Instant at a specified time zone. Supported values are Date or Instant. Only use this one for display purposes, never store a date in something else than UTC.
List<String> getAvailableTimeZoneIds()Returns a list of available time zone ids. A more or less complete list can also be found here
int getField(Object value, String chronoFieldString)Obtains a 'slice of time' by specifying a ChronoField as a String. The chrono field can be specified either as the display name or the enum name. Supported values are Date, Instant, LocalDate, LocalDateTimeor an ISO8601 formatted String. A list of all chrono fields can be found here. Example: flw.time.getField(flw.time.now(), 'DAY_OF_WEEK'), or flw.time.getField(flw.time.now(), 'AlignedWeekOfYear')
boolean isWeekend(Object value)Determines whether the given value represents a weekend. Supported values are Date, Instant, LocalDate, LocalDateTime or a ISO8601 formatted String.
Instant fullDateTimeInstant(int year, int month, int day, int hour, int minute, int second)Creates an Instant with the given values in UTC time zone.
Date fullDateTimeDate(int year, int month, int day, int hour, int minute, int second)Creates a Date with the given values.
Object plusSeconds(Object value, long seconds)Adds seconds to a given value. Supported values are Date, Instant, LocalDate, LocalDateTime or an ISO8601 formatted String.
Object plusMinutes(Object value, long minutes)Adds minutes to a given value. Supported values are Date, Instant, LocalDate, LocalDateTime or an ISO8601 formatted String.
Object plusHours(Object value, long hours)Adds hours to a given value. Supported values are Date, Instant, LocalDate, LocalDateTime or an ISO8601 formatted String.
Object plusDays(Object value, long days)Adds days to a given value. Supported values are Date, Instant, LocalDate, LocalDateTime or an ISO8601 formatted String.
Object plusWeeks(Object value, long days)Adds weeks to a given value. Supported values are Date, Instant, LocalDate, LocalDateTime or an ISO8601 formatted String.
Object plusMonths(Object value, long days)Adds month to a given value. Supported values are Date, Instant, LocalDate, LocalDateTime or an ISO8601 formatted String.
Object plusYears(Object value, long days)Adds years to a given value. Supported values are Date, Instant, LocalDate, LocalDateTime or an ISO8601 formatted String.
Object plusDuration(Object value, String iso8601Duration)Adds an ISO8601 encoded duration to a given value. Supported values are Date, Instant, LocalDate, LocalDateTime or an ISO8601 formatted String. Examples: flw.time.plusDuration(flw.time.now(), 'P1Y') (adds one year to now), flw.time.plusDuration(flw.time.now(), 'P14D') (adds 14 days to now), flw.time.plusDuration(flw.time..now(), 'PT30M10S') (adds 30 minutes and 10 seconds to now).
Object minusSeconds(Object value, long seconds)Subtracts seconds from a given value. Supported values are Date, Instant, LocalDate, LocalDateTime or an ISO8601 formatted String.
Object minusMinutes(Object value, long minutes)Subtracts minutes from a given value. Supported values are Date, Instant, LocalDate, LocalDateTime or an ISO8601 formatted String.
Object minusHours(Object value, long hours)Subtracts hours from a given value. Supported values are Date, Instant, LocalDate, LocalDateTime or an ISO8601 formatted String.
Object minusDays(Object value, long days)Subtracts days from a given value. Supported values are Date, Instant, LocalDate, LocalDateTime or an ISO8601 formatted String.
Object minusWeeks(Object value, long days)Subtracts weeks from a given value. Supported values are Date, Instant, LocalDate, LocalDateTime or an ISO8601 formatted String.
Object minusMonths(Object value, long days)Subtracts month from a given value. Supported values are Date, Instant, LocalDate, LocalDateTime or an ISO8601 formatted String.
Object minusYears(Object value, long days)Subtracts years from a given value. Supported values are Date, Instant, LocalDate, LocalDateTime or an ISO8601 formatted String.
Object minusDuration(Object value, String iso8601Duration)Subtracts an ISO8601 encoded duration from a given value. Supported values are Date, Instant, LocalDate, LocalDateTime or an ISO8601 formatted String. Examples: flw.time.minusDuration(flw.time.now(), 'P1Y') (subtracts one year from now), flw.time.minusDuration(flw.time.now(), 'P14D') (subtracts 14 days from now), flw.time.minusDuration(flw.time..now(), 'PT30M10S') (subtracts 30 minutes and 10 seconds from now).
long secondsOfDuration(String iso8601Duration)Returns the number of seconds in a ISO duration string, e.g. PT60M returns 3600.
boolean isBefore(Object firstValue, Object secondValue)Checks if the first value is before the second value. Supported values are Date, Instant, LocalDate, LocalDateTime or an ISO8601 formatted String. The values don't need to be the same type, they will be converted automatically, if needed.
boolean isBeforeOrEqual(Object firstValue, Object secondValue)Checks if the first value is before or equals to the second value. Supported values are Date, Instant, LocalDate, LocalDateTime or an ISO8601 formatted String. The values don't need to be the same type, they will be converted automatically, if needed.
boolean isAfter(Object firstValue, Object secondValue)Checks if the first value is after the second value. Supported values are Date, Instant, LocalDate, LocalDateTime or an ISO8601 formatted String. The values don't need to be the same type, they will be converted automatically, if needed.
boolean isAfterOrEqual(Object firstValue, Object secondValue)Checks if the first value is after or equal to the second value. Supported values are Date, Instant, LocalDate, LocalDateTime or an ISO8601 formatted String. The values don't need to be the same type, they will be converted automatically, if needed.
boolean areEqual(Object firstValue, Object secondValue)Checks if the first value is equal to the second value. Supported values are Date, Instant, LocalDate, LocalDateTime or an ISO8601 formatted String. The values don't need to be the same type, they will be converted automatically, if needed.
boolean isBeforeTime(Object value, String timeZoneId, int hours, int minutes, int seconds)Checks if the given value is before a certain time in a given time zone. Supported values are Date, Instant, LocalDate, LocalDateTime or an ISO8601 formatted String.
boolean isAfterTime(Object value, String timeZoneId, int hours, int minutes, int seconds)Checks if the given value is after a certain time in a given time zone. Supported values are Date, Instant, LocalDate, LocalDateTime or an ISO8601 formatted String.
long getFieldFromDurationBetweenDates(Object firstValue, Object secondValue, String chronoUnitString)Returns the duration between two values. Supported values are Date, Instant, LocalDate, LocalDateTime or an ISO8601 formatted String. The following units are supported: Nanos, Micros, Millis, Seconds, Hours, HalfDays, Days, Weeks, Months, Years, Decades, Centuries, Millenia. Please note that the number will always be a long, i.e. the number will always be rounded.
long secondsBetween(Object firstValue, Object secondValue)Return the number of seconds between two values. Supported values are Date, Instant, LocalDate, LocalDateTime or an ISO8601 formatted String.
long minutesBetween(Object firstValue, Object secondValue)Return the number of minutes between two values. Supported values are Date, Instant, LocalDate, LocalDateTime or an ISO8601 formatted String.
long hoursBetween(Object firstValue, Object secondValue)Return the number of hours between two values. Supported values are Date, Instant, LocalDate, LocalDateTime or an ISO8601 formatted String.
long daysBetween(Object firstValue, Object secondValue)Return the number of days between two values. Supported values are Date, Instant, LocalDate, LocalDateTime or an ISO8601 formatted String.
long weeksBetween(Object firstValue, Object secondValue)Return the number of weeks between two values. Supported values are Date, Instant, LocalDate, LocalDateTime or an ISO8601 formatted String.
long monthsBetween(Object firstValue, Object secondValue)Return the number of month between two values. Supported values are Date, Instant, LocalDate, LocalDateTime or an ISO8601 formatted String.
long yearsBetween(Object firstValue, Object secondValue)Return the number of years between two values. Supported values are Date, Instant, LocalDate, LocalDateTime or an ISO8601 formatted String.
long getTimeZoneOffset(Object value, String timeZoneId)Calculates the number of seconds a specific point in time at a specified time zone is set off from UTC. Supported values are Date, Instant, LocalDate, LocalDateTime or an ISO8601 formatted String.

String Utilities

The scripting API also supports utilities around string handling, which is accessible through flw.string.

You can use the same functionality as with an expression using flwStringUtils.

Here is a list of available functions:

FunctionDescription
String toUpperCase(Object text)Turns all letters of an object to uppercase. Supported values are String, a Json TextNode or null.
String toLowerCase(Object text)Turns all letters of an object to lowercase. Supported values are String, a Json TextNode or null.
String capitalize(Object text)Capitalizes a text, i.e. sets the first letter to uppercase. Supported values are String, a Json TextNode or null.
String trimWhitespace(Object text)Removes all leading and trailing whitespaces from a text. Supported values are String, a Json TextNode or null.
boolean hasText(Object text)Checks whether a string contains text (is not null or empty). Supported values are String, a Json TextNode or null.
boolean contains(Object text, String otherText)Checks if a strings contains another string. Supported values are String, a Json TextNode or null.
boolean containsIgnoreCase(Object text, String otherText)Checks if a strings contains another string ignoring the case. Supported values are String, a Json TextNode or null.
boolean matches(Object text, String regularExpression)Checks whether a text matches a regular expression. Supported values are String, a Json TextNode or null.
boolean equals(Object text, String otherText)Checks if two strings are the equal. Supported values are String, a Json TextNode or null.
boolean equalsIgnoreCase(Object text, String otherText)Checks if two strings are the equal, ignoring the case. Supported values are String, a Json TextNode or null.
String substring(Object text, int from, int to)Returns a substring within a provided character range. Index is 0 based, from is inclusive, to is exclusive. Supported values are String, a Json TextNode or null.
String substringFrom(Object text, int from)Returns the text starting at a given position (index is 0 based). Supported values are String, a Json TextNode or null.
List<String> split(Object text, String delimiter)Splits a text into a collection with a given delimiter. The delimiter can be a single character, e.g. a semicolon or a regular expression. Supported values are String, a Json TextNode or null.
String join(Collection<String> collection, String delimiter)Concatenates all entries of a list or collection to a single string using a given delimiter. Supported values are String, a Json TextNode or null.
String newline()Returns a new line / linefeed character.
String carriageReturn()Returns the carriage return character.
String escapeHtml(Object text)Escapes the characters in an object using HTML entities. Supported values are String, a Json TextNode or null.
String unescapeHtml(Object text)Unescapes a string containing entity escapes to a string containing the actual Unicode characters corresponding to the escapes. Supported values are String, a Json TextNode or null.

Math Utilities

The scripting API also supports utilities with mathematical operations, which is accessible through flw.math.

You can use the same functionality as with an expression using flwMathUtils.

Here is a list of available functions:

FunctionDescription
double sum(Collection<Double> numbers)Calculates the sum of a list of numbers.
double average(Collection<Double> numbers)Calculates the average of a list of numbers.
double floor(double number)Returns the next lower integer of a provided number.
double ceil(double number)Returns the next higher integer of a provided number.
double round(double number)Rounds a number to an integer value.
double round(double number, int scale)Round a number to a maximum of decimal places using RoundingMode#HALF_UP.
double min(Collection<Double> numbers)Returns the lowest number from a list of numbers.
double max(Collection<Double> numbers)Returns the highest number from a list of numbers.
double abs(double number)Returns the absolute value of a number.
double median(Collection<Double> numbers)Returns the median of a list of numbers.
double parseDouble(String string)Converts a string into a double value.
int parseInt(String string)Converts a string into an integer value.

Locale Utilities

The scripting API also provides utilities to work with locales, countries and languages, which is accessible through flw.locale.

You can use the same functionality as with an expression using flwLocaleUtils.

Here is a list of available functions:

FunctionDescription
Locale getLocaleForLanguageTag(String languageTag)Returns the locale with the given language tag, e.g. 'ch-DE'.
List<Locale> getAvailableLocales()Returns a list of available locales.
Locale getDefaultLocale()Returns the system default locale.
List<String> getAllCountryCodes()Returns a list of all 2-letter ISO country codes.
List<String> getAllLanguageCodes()Returns a list of all ISO language codes, e.g. "de" (NOT "de-CH").
String getLanguageDisplayName(String languageIsoCode, String displayLanguageTag)Returns a single language name in a certain language, e.g. "German" or "Spanish".
String getCountryDisplayName(String languageTag, String displayLanguageTag)Returns a single country name in a certain language, e.g. "Switzerland" or "Germany".
List<String> getAllLanguageDisplayNames(String displayLanguageTag)Returns a list of all language names in a certain language.
List<String> getAllCountryDisplayNames(String displayLanguageTag)Returns a list of all country names in a certain language.

Formatting Utilities

The scripting API also provides utilities around formatting, which is accessible through flw.format.

You can use the same functionality as with an expression using flwFormatUtils.

Here is a list of available functions:

FunctionDescription
String formatString(String text, Object... substitutes)Formats a string according to the Java formatter specification, see here or here
String formatDate(Object value, String dateFormat)Formats the value to a string with the given format. Supported values are Date, Instant, LocalDate, LocaDateTime or an ISO8601 formatted string.
String formatDecimal(String pattern, double decimal)Formats a string according to the Java formatter specification with a decimal formatter in the default locale. See
String formatStringWithLocale(String languageTag, String text, Object... substitutes)Formats a string according to the Java formatter specification. The string is formatted according to the format specified in the locale of the provided language tag. See here or here
String formatCurrencyWithLocale(String currencyCode, double amount, String languageTag)Formats a currency amount according to the format specified in the locale of the provided language tag.