How to check whether input value is integer or float?
Suppose 312/100=3.12 Here i need check whether 3.12 is a float value or integer value, i.e., without any decimal
You can use RoundingMode.#UNNECESSARY if you want/accept exception thrown otherwise
new BigDecimal(value).setScale(2, RoundingMode.UNNECESSARY);
If this rounding mode is specified on an operation that yields an inexact result, an ArithmeticException is thrown.
Exception if not integer value:
java.lang.ArithmeticException: Rounding necessary