Set the Decimal Place of a Big Decimal Value in Java
Description
The following code shows how to set the Decimal Place of a Big Decimal Value.
Example
//w w w . j a v a 2s. c om
import java.math.BigDecimal;
public class Main {
public static void main(String[] argv) throws Exception {
int decimalPlaces = 2;
BigDecimal bd = new BigDecimal("123456789.0123456890");
System.out.println();
bd = bd.setScale(decimalPlaces, BigDecimal.ROUND_DOWN);
String string = bd.toString();
}
}
Home »
Java Tutorial »
Java Data Type »
Java Tutorial »
Java Data Type »