I want to validate that a float or Double has minimum 5 numbers after decimal points.This is the code I have written

private boolean invalidDecimalPrecision(Double point)
{
    int decimalPrecision = BigDecimal.valueOf(point).scale();

    return !(decimalPrecision >= 5);

}

Is it good enough or do I have to handle specific case of negative scale numbers as well

有帮助吗?

解决方案

The plugin which generates Pojos has accepted the feature request for adding an option to represent Double as BigDecimal

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top