Java BigDecimal to convertNullToBigDecimal(Object orgStr)

Here you can find the source of convertNullToBigDecimal(Object orgStr)

Description

: convertNullToDate

License

Apache License

Parameter

Parameter Description

Exception

Parameter Description

Return

Date

Declaration

public static BigDecimal convertNullToBigDecimal(Object orgStr) 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.math.BigDecimal;

public class Main {

    public static BigDecimal convertNullToBigDecimal(Object orgStr) {
        if (orgStr == null || orgStr.toString().equals("")) {
            return new BigDecimal("0");
        } else {/*  w  w w.  j a  v a2  s.co  m*/
            return (BigDecimal) (orgStr);
        }
    }

    public static String toString(Object[] objArr) {
        if (objArr == null) {
            return null;
        }

        StringBuffer buf = new StringBuffer("[");
        for (int i = 0; i < objArr.length; i++) {
            buf.append((i > 0 ? "," : "") + objArr[i]);
        }
        buf.append("]");
        return buf.toString();
    }

    public static String toString(Object obj) {
        if (obj instanceof String) {
            return "\"" + obj + "\"";
        }
        if (obj instanceof Object[]) {
            return toString((Object[]) obj);
        } else {
            return String.valueOf(obj);
        }
    }
}

Related

  1. convertBigDecimalToString(BigDecimal bigValue)
  2. convertDoubleToBigDecimal(Double value)
  3. convertDoubleToBigDecimal(final Double score, final int decimalPlaces)
  4. convertFeetToInches(BigDecimal feet)
  5. convertHoursToMillis(BigDecimal hours)
  6. convertRadiansToDegrees(BigDecimal radians)
  7. convertRating(BigDecimal rating)
  8. convertSecondsToMillis(BigDecimal seconds)
  9. convertStringToBigDecimal(String strValue)