Java Number Convert convertToJBPM(Object value)

Here you can find the source of convertToJBPM(Object value)

Description

A helper to convert result variables for jBPM.

License

Apache License

Parameter

Parameter Description
value The input value, String or BigDecimal

Return

Value jBPM output value, Integer, Double or String

Declaration

public static Object convertToJBPM(Object value) 

Method Source Code


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

import java.math.BigDecimal;

public class Main {
    /**/* w  ww . j a  v  a2  s  . c  o m*/
     * A helper to convert result variables for jBPM.
     * Afm will return integer and double values as BigDecimal, this
     * helper will convert those to Integer and Double for jBPM compatibility.
     *
     * @param value The input value, String or BigDecimal
     * @return Value jBPM output value, Integer, Double or String
     */
    public static Object convertToJBPM(Object value) {

        if (BigDecimal.class.isInstance(value)) {
            BigDecimal v = (BigDecimal) value;
            if (v.scale() == 0) {
                return v.intValue();
            }
            return v.doubleValue();
        }

        return value;
    }
}

Related

  1. convertsToLong(double v)
  2. convertStringToObjectWrapper(String className, String value)
  3. convertToDecimal(Number n)
  4. convertToHours(long workingDuration)
  5. convertToInchesOfMercury(double altimeterSetting, String unit)
  6. convertToKg(int value)
  7. convertToLong(String decimal, int precision)
  8. ConvertToMeters(double distance)
  9. convertToMm(double value)