Display two digit after decimal point

Hey guys,

i want to display two digits after decimal point like below, currently it is showing four digits.

currently i am getting like this

  1. 10.99 * 5.00 = 54.9500
  2. 10.99 * 5.45 = 59.8955

i want like this

  1. 10.99 * 5.00 = 54.95
  2. 10.99 * 5.45 = 59.8955 (round it and display only 2 digit)

my code like this

def totalPrice = WebUI.concatenate([
Currency.getInstance(productResult.getObject("ISOCurrencyCode")).getSymbol(),
productResult.getObject("Quantity") * productResult.getObject("PriceListPrice")] as String[], FailureHandling.STOP_ON_FAILURE)
Double number1 = Double.parseDouble("59.8955")NumberFormat nf = NumberFormat.getInstance()nf.setMaximumFractionDigits(2)println nf.format(number1)//output59.9

If you want exactly 2 decimal numbers (59.90 in this case), add

nf.setMinimumFractionDigits(2)
1 Like