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 . |
toBoolean(Boolean b) |
Boolean |
Converts a Boolean to a Boolean value. For example, toBoolean("FALSE") returns false . |
|
Double |
Converts a Boolean, Number, or String to a Double. |
|
Long |
Converts a Boolean, Date, or Double to a Long. |
toLong(String s) |
Long |
Converts a String representation of a long to a Long. For example, toBoolean("123") returns 123 . Invalid Strings (for example, one that contains letters) return null . |
toString(Object arg) |
String |
Converts an Object of any data type to a String. |