Java examples for Language Basics:BigDecimal
Setting the Decimal Place of a Big Decimal Value
import java.math.BigDecimal; public class Main { public static void main(String[] args) { int decimalPlaces = 2; BigDecimal bd = new BigDecimal("123"); // Truncates the big decimal value. bd = bd.setScale(decimalPlaces, BigDecimal.ROUND_DOWN); String string = bd.toString(); System.out.println(string);//w w w . j a v a2s . co m } }