You can convert it to a BigDecimal
and then get the intValue()
from it.
int val = new BigDecimal(eval.toString()).intValue();
Note that intValue()
will trim the Decimal
in the result. If you want to throw an exception, in case that is happening, use intValueExact()
which throws an ArithmeticException
.