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; }}