Java Utililty Methods BigDecimal Format

List of utility methods to do BigDecimal Format

Description

The list of methods to do BigDecimal Format are organized into topic(s).

Method

StringgetFormatSizeByKB(long size)
get Format Size By KB
double kiloByte = size / 1024;
if (kiloByte < 1) {
    return size + "KB";
double megaByte = kiloByte / 1024;
if (megaByte < 1) {
    BigDecimal result1 = new BigDecimal(Double.toString(kiloByte));
    return result1.setScale(2, BigDecimal.ROUND_HALF_UP).toPlainString() + "MB";
...
booleanisLess(float formateValue1, float formateValue2)
is Less
BigDecimal n1 = new BigDecimal(formateValue1);
BigDecimal n2 = new BigDecimal(formateValue2);
return n1.compareTo(n2) == -1 ? true : false;
StringtimeToEMTFormat(long elapsedTimeMillis)
Chess base EMT format.
double elapsedTimeInSeconds = elapsedTimeMillis / 1000.0;
BigDecimal bigDecimal = new BigDecimal(elapsedTimeInSeconds);
bigDecimal = bigDecimal.setScale(3, BigDecimal.ROUND_HALF_UP);
return "[%emt " + bigDecimal.toString() + "]";
StringtoNormalFenFormat(String fen)
to Normal Fen Format
return String.valueOf(new BigDecimal(fen));
StringunformattedFromDouble(double n, int decimals)
Convert a double to the unformatted form.
return unformattedFromBigDecimal(new BigDecimal(n).setScale(decimals, BigDecimal.ROUND_HALF_UP));