toString
def toString = {val, scaleNum = 0, roundType = BigDecimal.ROUND_HALF_UP, nullDefVal = '' ->
xxx
}
Formats numbers or number strings consistently.
Parameter
Description
Default Value
val
The numerical value to be formatted. When configured to non-numeric values, the string representation is returned.
scaleNum
The new scale for the val field value, which takes effect only for single numbers and number strings.
0
roundType
The rounding type for single numbers or number strings.
0: Round Up
1: Round Down
2: Round Ceiling
3: Round Floor
4: Round Half Up
5: Round Half Down
6: Round Half Even
7: Round Necessary
For more information, see the BigDecimal class documentation.
4
nullDefVal
Default value for null.
Example Usage
Transform Function
Evaluation Results
toString(null)
'' (empty string)
toString(null, 0, 0, 'abcd')
"abcd"
toString(6)
"6"
toString(6, 2)
"6.00"
toString(6.12345, 2)
"6.12"
toString(6.12545, 2)
"6.13"
toString(6.12545, 2, 1)
"6.12"
toString('6', 2)
"6.00"
toString('6.12545', 2)
"6.13"
For more information:
Was this helpful?