Skip to main content Skip to complementary content

java:call

Calls a static or non-static method of a Java class or object in data shaping expressions.

Arguments

For static method calls:

  1. Class name (string).
  2. Method name (string).
  3. Arguments of the method (any type).

For non-static method calls:

  1. Java object instance created with java:new.
  2. Method name (string).
  3. Arguments of the method (any type).

Examples

Calling a static method:

java:call("java.lang.Double", "compare", 3.1415d, 1.51d)

This example compares two double values using Java Double.compare() method.

Calling a non-static method:

java:call(java:new("java.util.Random", 536815L), "nextInt", 100)

This example creates a Random object with a seed and calls its nextInt method.

Chaining Java calls:

java:call(java:call("java.lang.String", "valueOf", 100), "concat", "$")

This example converts the integer 100 to a string, then concatenates a dollar sign.

java:call(java:call(java:new("java.text.SimpleDateFormat", "yyyy-MM-dd"), "parse", "2018-10-15"), "getDate")

This example creates a SimpleDateFormat object, parses a date string, and retrieves the date.

Did this page help you?

If you find any issues with this page or its content – a typo, a missing step, or a technical error – please let us know!