문제

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