Question:
How to Convert a BigDecimal to an int?
Converting BigDecimal to Integer
Converting BigDecimal to Integer
Answer:
bigdecimal.intValue();
Code:
import java.math.*; public class BigDecimalTest { public static void main(String[] args) { BigDecimal big = new BigDecimal(123.456); int x = big.intValue(); System.out.println(x); } }
Output:
$ java BigDecimalTest 123