package com.sprucetec.tms.utils;
import java.math.BigDecimal;
import java.text.SimpleDateFormat;
import java.util.Calendar;
/**
* BigDecimal工具类
* @author yangweiqiang
* @date 2016/12/1
*/
public class BigDecimalUtils {
private BigDecimalUtils(){}
/**
* 如果value为null,则转换为 0
* @param value
* @return
*/
public static BigDecimal nullToZero(BigDecimal value){
if (null == value){
return BigDecimal.ZERO;
}
return value;
}
/**
* 判断是否为0
* @param money
* @return
*/
public static boolean isZero(BigDecimal money) {
return BigDecimal.ZERO.compareTo(money)==0;
}
/**
* 大于0
*/
public static boolean greaterThanZero(BigDecimal value){
if (value==null) return false;
return value.compareTo(BigDecimal.ZERO) == 1;
}
/**
* 小于0
*/
public static boolean lessThanZero(BigDecimal value){
if (value==null) return false;
return value.compareTo(BigDecimal.ZERO) == -1;
}
/**
* v1 > v2
*/
public static boolean greater(BigDecimal v1, BigDecimal v2) {
if (v1==null || v2==null) return false;
return v1.compareTo(v2) == 1;
}
/**
* v1 < v2
*/
public static boolean less(BigDecimal v1, BigDecimal v2) {
if (v1==null || v2==null) return false;
return v1.compareTo(v2) == -1;
}
/**
* v1 = v2
*/
public static boolean equals(BigDecimal v1, BigDecimal v2) {
if (v1==null || v2==null) return false;
return v1.compareTo(v2) == 0;
}
}