format Half Up BigDecimal - Java java.math

Java examples for java.math:BigDecimal Format

Description

format Half Up BigDecimal

Demo Code


//package com.java2s;
import java.math.BigDecimal;

public class Main {
    public static BigDecimal formatHalfUpBigDecimal(BigDecimal bigDecimal) {
        return new BigDecimal(bigDecimal.doubleValue()).setScale(2,
                BigDecimal.ROUND_HALF_UP);
    }// w  w w .jav  a 2s  .c  o m
}

Related Tutorials