Conversion functions change a value from one data type to another.
This table describes the conversion functions that Transform supports. The same functions are described in the Transform API Reference (Groovydoc).
These functions rely on the Java dateFormat: http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html.
User Function | Return Data Type | Description |
---|---|---|
toBoolean(Number n) | Boolean | Converts a number to a Boolean value; for example, toBoolean(1) evaluates to true. Note that only 0 evaluates to false. Any number other than 0 (including negative numbers) evaluates to true. |
toBoolean(String s) | Boolean | Converts a String to a Boolean value; for example, toBoolean("yes") returns false. Note that this method only evaluates to true if the String is "true". Capitalization is ignored, so "true", "TRUE", and "tRuE" are all true. |
toDouble(Boolean b) toDouble(Integer i) toDouble(Long l) toDouble(String s) |
Double | Converts a Boolean, Integer, Long, or String to a Double. |
toInteger(Double d) toInteger(Long l) toInteger(Boolean b) toInteger(String s) |
Integer | Converts a Double, Long, Float,
Boolean, or String to an Integer. If the original value is too large, causes an
exception.
Note: These functions are not supported in BDD 1.0.
|
toLong(Boolean b) toLong(Date d) toLong(Double d) |
Long | Converts a Boolean, Date, or Double to a Long. |
toLong(String s) | Long | Converts a valid String to a Long.
Invalid Strings (for example, one that contains letters) return
null.
Note: This function does not support locale parsing. If you need
to specify a locale to properly convert the String, use a different Groovy
method. For example, to properly convert the German String
"1.025,7" to a long, you could use
NumberFormat.getInstance(Locale.GERMANY).parse("1.025,7").
|
toString(Object arg) | String | Converts an Object of any data type to a String. |