javacast

Converts the data type of a CFML variable to pass as an argument to an overloaded method of a Java object.

javacast(type, variable) → returns Object

javacast Argument Reference

type
Required

The name of a java primative or a Java class name. Values:
  • boolean
  • double
  • float
  • int
  • long
  • string
  • null
  • byte
  • bigdecimal
  • char
  • short

variable
Required

A variable, java object or array.

Compatibility

ColdFusion:

CF 7+ Added null. CF 8+ added bigdecimal, byte, char, short and for casting arrays.

Examples sample code invoking the javacast function


Convert a ColdFusion Number to a Java double primative

Converts the number 180.0 degrees to radians using Java method: Math.toRadians(double degrees)

createObject("java", "java.lang.Math").toRadians( javacast("double", 180.0) )

Expected Result: 3.14159265359


Fork me on GitHub