Java Type Coerce coerceToDouble(Object o)

Here you can find the source of coerceToDouble(Object o)

Description

coerce To Double

License

Open Source License

Declaration

public static double coerceToDouble(Object o) 

Method Source Code

//package com.java2s;
// Released under the Apache License, Version 2.0

public class Main {
    public static double coerceToDouble(Object o) {
        if (o instanceof Number) {
            return ((Number) o).doubleValue();
        } else {/*from  w ww.ja v  a2 s  .c o m*/
            try {
                return Double.parseDouble(o.toString());
            } catch (NumberFormatException e) {
                return Double.NaN;
            }
        }
    }
}

Related

  1. coerceBool(Object obj)
  2. coerceBool(Object val)
  3. coerceIntoComboId(Long entityId)
  4. coerceIntoEntityId(Long comboId)
  5. coerceTagValueInt(String tag, Object val)
  6. coerceToEntrySize(String s)
  7. coerceToString(Object object)
  8. coerceToType(Object objectIn, Class clazz)
  9. coerceTypes(Class clazz, Object value)