get min value from two BigDecimal - Java java.math

Java examples for java.math:BigDecimal

Description

get min value from two BigDecimal

Demo Code


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

public class Main {
    public static void main(String[] argv) throws Exception {
        BigDecimal first = new BigDecimal("1234");
        BigDecimal second = new BigDecimal("1234");
        System.out.println(min(first, second));
    }//  w  w  w.jav  a2s .  c  o  m

    public static BigDecimal min(BigDecimal first, BigDecimal second) {
        if (first.doubleValue() > second.doubleValue()) {
            return second;
        }
        return first;
    }
}

Related Tutorials