Monday, August 17, 2009

How to use java BigDecimal


import java.math.BigDecimal;

public class DecimalTester {
public static void main(String args[]) {
BigDecimal value = new BigDecimal("0");
value = value.setScale(2, BigDecimal.ROUND_HALF_UP);
String ValueWithDouble = String.valueOf(value);
System.out.println("Tax : " + ValueWithDouble);
System.out.println("Tax : " + value.doubleValue());
}
}

No comments:

Post a Comment