get Fractional Count - Android java.lang

Android examples for java.lang:Math

Description

get Fractional Count

Demo Code


import android.support.annotation.NonNull;
import java.math.BigDecimal;

public class Main{
    public static int getFractionalCount(BigDecimal value) {
        String string = value.stripTrailingZeros().toPlainString();
        int index = string.indexOf(".");
        return index < 0 ? 0 : string.length() - index - 1;
    }// w  w w . j  a v  a  2s .c  om
    @NonNull
    public static String toPlainString(BigDecimal value) {
        return NpeUtils.getNonNull(value).toPlainString();
    }
}

Related Tutorials