フォーマッタを使用した数字の書式設定
この例では、Groovyを使用して数値を書式設定する方法を示します。
//To format a number numberVal as a floating point value with two (2) decimal places and thousands separator you can do:
def locale = adf.context.getLocale();
def numberVal = 12345;
Double dv = numberVal as Double
def fmt = new Formatter(locale)
def ret = (dv != null) ? fmt.format('%,.2f', dv) : null
//To format a number numberVal as a floating point value with three (3) decimal places and no thousands separator you can do:
Double dv1 = numberVal as Double
def fmt1 = new Formatter(locale)
def ret1 = (dv1 != null) ? fmt1.format('%.3f', dv1) : null
//To format a number value with no decimal places to have a zero-padded width of 8, you can do:
Long lv = numberVal as Long
def fmt2 = new Formatter(locale)
def ret2 = (lv != null) ? fmt2.format('%08d', lv) : null