On Tue, 2009-10-27 at 11:19 -0400, Michael Potter wrote:
[ . . . ]
> BigDecimal bd = new BigDecimal("123456.798")
> def df = new java.text.DecimalFormat("#,###,###,##0.00" )
> String s = df.format(bd)
> assert s == "123,456.80"
>
> Sorry about the hard coded types, but I want to make sure that the
> numbers are not converted to double.
All floating point literals and values are BigDecimal by default -- you
actually have to work very hard to get doubles in Groovy.
def bd = 123456.798
assert bd.class == BigDecimal
def df = new java.text.DecimalFormat ( '#,###,###,##0.00' )
def s = df.format ( bd )
assert s == "123,456.80"
--
Russel.
=============================================================================
Dr Russel Winder Partner
xmpp:
russel@...
Concertant LLP t: +44 20 7585 2200, +44 20 7193 9203
41 Buckmaster Road, f: +44 8700 516 084 voip: sip:
russel.winder@...
London SW11 1EN, UK m: +44 7770 465 077 skype: russel_winder