Example usage for java.lang Double valueOf

List of usage examples for java.lang Double valueOf

Introduction

In this page you can find the example usage for java.lang Double valueOf.

Prototype

@HotSpotIntrinsicCandidate
public static Double valueOf(double d) 

Source Link

Document

Returns a Double instance representing the specified double value.

Usage

From source file:Main.java

/**
 * //w  w w . j  a  v a 2 s  .c  om
 * @param value
 * @return double[]
 */
public static double[] toDoubleArray(final String value) {
    if (value == null) {
        return new double[] {};
    }

    final int BRACKET_LENGTH = 1;
    final String strippedValue = value.substring(BRACKET_LENGTH, value.length() - BRACKET_LENGTH);
    final StringTokenizer tokenizer = new StringTokenizer(strippedValue, ELEMENT_SEPARATOR);
    final Collection<Double> doubleCollection = new ArrayList<>();

    while (tokenizer.hasMoreTokens()) {
        doubleCollection.add(Double.valueOf(tokenizer.nextToken().trim()));
    }

    return toDoubleArray(doubleCollection);
}

From source file:com.glaf.base.utils.ParamUtil.java

public static double getDouble(Map<String, Object> dataMap, String key) {
    double result = 0.0;
    Object value = dataMap.get(key);
    if (value != null && StringUtils.isNotEmpty(value.toString())) {
        if (value instanceof String) {
            String tmp = (String) value;
            result = Double.valueOf(tmp);
        } else if (value instanceof Integer) {
            Integer x = (Integer) value;
            result = x.doubleValue();//w w w. j  a v a  2s.  co  m
        } else if (value instanceof Long) {
            Long x = (Long) value;
            result = x.doubleValue();
        } else if (value instanceof Double) {
            Double x = (Double) value;
            result = x.doubleValue();
        }
    }
    return result;
}

From source file:org.hawkular.alerts.api.model.condition.ThresholdConditionEval.java

public ThresholdConditionEval(ThresholdCondition condition, Data data) {
    super(Type.THRESHOLD, condition.match(Double.valueOf(data.getValue())), data.getTimestamp(),
            data.getContext());/*www . j a  v  a 2 s.c om*/
    this.condition = condition;
    this.value = Double.valueOf(data.getValue());
}

From source file:net.sf.zekr.common.util.VelocityUtils.java

public Number toDouble(Object num) {
    return Double.valueOf(num.toString());
}

From source file:com.ottogroup.bi.streaming.operator.json.aggregate.functions.DoubleContentAggregateFunctionTest.java

/**
 * Test case for {@link DoubleContentAggregateFunction#sum(Double, Double)} being
 * provided null as input to old sum parameter
 *///w  w w .ja  v  a 2  s.c  o m
@Test
public void testSum_withNullOldSum() throws Exception {
    Assert.assertEquals(Double.valueOf(1.23),
            new DoubleContentAggregateFunction().sum(null, Double.valueOf(1.23)));
}

From source file:net.jofm.format.NumberFormat.java

@Override
protected Object doParse(String value, Class<?> destinationClazz) {
    Number result;//from  w w w. j  a v  a 2  s . c  om
    try {
        if (StringUtils.isNotEmpty(format)) {
            DecimalFormat formatter = new DecimalFormat(format);
            result = formatter.parse(value);
        } else {
            result = Double.valueOf(value);
        }
    } catch (Exception pe) {
        throw new FixedMappingException(
                "Unable to parse the value '" + value + "' to number with format '" + format + "'");
    }

    return convert(result, destinationClazz);
}

From source file:com.wabacus.system.datatype.DoubleType.java

public Object getColumnValue(ResultSet rs, int iindex, AbsDatabaseType dbtype) throws SQLException {
    return Double.valueOf(rs.getDouble(iindex));
}

From source file:org.hawkular.alerts.api.model.condition.ThresholdRangeConditionEval.java

public ThresholdRangeConditionEval(ThresholdRangeCondition condition, Data data) {
    super(Type.RANGE, condition.match(Double.valueOf(data.getValue())), data.getTimestamp(), data.getContext());
    this.condition = condition;
    this.value = Double.valueOf(data.getValue());
}

From source file:com.nominanuda.hyperapi.JsonAnyValueDecoder.java

@Override
protected Object decodeInternal(AnnotatedType p, HttpEntity entity) throws IOException {
    String s = IO.readAndCloseUtf8(entity.getContent());
    if ("null".equals(s)) {
        return null;
    } else if ("true".equals(s) || "false".equals(s)) {
        return Boolean.valueOf(s);
    } else if (Maths.isNumber(s)) {
        if (Maths.isInteger(s)) {
            return Long.valueOf(s);
        } else {// w w w  . ja v a 2 s.c o m
            return Double.valueOf(s);
        }
    } else if (s.startsWith("\"") && s.length() > 1) {
        return STRUCT.jsonStringUnescape(s.substring(1, s.length() - 1));
    } else {
        DataStruct ds = STRUCT.parse(new StringReader(s));
        return ds;
    }
}

From source file:com.imagelake.earnings.Servlet_EarningsValues.java

protected void doGet(HttpServletRequest request, HttpServletResponse response)
        throws IOException, ServletException {
    PrintWriter out = response.getWriter();
    try {/*from w w w  .j av a  2 s .c o  m*/
        String uid = request.getParameter("uid");
        if (uid != null && !uid.equals("")) {

            uidd = Integer.parseInt(uid);

            PaymentPreferences pp = ppimp.getPendingEarning(uidd, 1);
            double pd = 00.00;
            double ad = 00.00;
            if (pp != null) {
                pd = pp.getAmount();
                DecimalFormat df1 = new DecimalFormat("#.##");
                pd = Double.valueOf(df1.format(pd));

            }

            SellerIncome sin = sidi.getSellerIncome(uidd);
            ad = sin.getTotal();
            DecimalFormat df = new DecimalFormat("#.##");
            ad = Double.valueOf(df.format(ad));

            double netamo = ad - pd;
            DecimalFormat df2 = new DecimalFormat("#.##");
            netamo = Double.valueOf(df2.format(netamo));

            JSONObject jo = new JSONObject();
            jo.put("pe", pd);
            jo.put("ab", ad);
            jo.put("ne", netamo);

            out.write("json=" + jo.toJSONString());
        }
    } catch (Exception e) {
        e.printStackTrace();

    }
}