Converts value into doubles or returns null when conversion is not possible.

@param value the value to convert.
@return double value or null when conversion is not supported.
162381
public static Double toNullableDouble(Object value) {
		if (value == null)
			return null;

		if (value instanceof Date)
			return (double) ((Date) value).getTime();
		if (value instanceof Calendar)
			return (double) ((Calendar) value).getTimeInMillis();
		if (value instanceof Duration)
			return (double) ((Duration) value).toMillis();

		if (value instanceof Boolean)
			return (boolean) value ? 1.0 : 0.0;

		if (value instanceof Integer)
			return (double) ((int) value);
		if (value instanceof Short)
			return (double) ((short) value);
		if (value instanceof Long)
			return (double) ((long) value);
		if (value instanceof Float)
			return (double) ((float) value);
		if (value instanceof Double)
			return (double) value;

		if (value instanceof String)
			try {
				return Double.parseDouble((String) value);
			} catch (NumberFormatException ex) {
				return null;
			}

		return null;
	}
560872
static double asDouble(Object value) throws ProvidenceConfigException {
        if (value instanceof Number) {
            return ((Number) value).doubleValue();
        } else if (value instanceof Numeric) {
            return ((Numeric) value).asInteger();
        }
        throw new ProvidenceConfigException(
                "Unable to convert " + value.getClass().getSimpleName() + " to a double");
    }
610408
public static float toFloat(final Object value) {
		if (value instanceof Float) {
			return (float) value;
		}
		if (value == null) {
			return 0;
		}
		return new Float(value.toString());
	}
913876
public static double format(double value) {
        if (value == Double.MAX_VALUE) {
            return value;
        }

        long factor = (long) Math.pow(10, 2);
        value = value * factor;
        double tmp = Math.floor(value);
        return tmp / factor;
    }
618871
public void put(Double value) {
		if (value == null) {
			this.compiledStatement.bindNull(compiledStatementBindIndex++);
		} else {
			this.compiledStatement.bindDouble(compiledStatementBindIndex++, value);
		}
	}
634688
public static Double asDouble(Object value) {
    double doubleValue;
    switch (value.getClass().getCanonicalName()) {
      case "java.math.BigDecimal":
        doubleValue = ((BigDecimal) value).doubleValue();
        break;
      case "java.lang.Integer":
        doubleValue = ((Integer) value).doubleValue();
        break;
      default:
        doubleValue = (Double) value;
        break;
    }
    return doubleValue;
  }
391944
public static Double toDouble(Object value) {
        if (value == null) {
            return null;
        } else if (value instanceof Double) {
            return (Double) value;
        } else if (value instanceof Number) {
            return ((Number) value).doubleValue();
        } else {
            try {
                return Double.valueOf(value.toString().trim());
            } catch (NumberFormatException e) {
                throw new ConversionException("failed to convert: '" + value + "' to Double", e);
            }
        }
    }
946923
public static Double checkNull(Double value, double elseValue) {
        return checkNull(value, Double.valueOf(elseValue));
    }
172148
public DoubleConstant getDoubleByValue(double value)
  {
    for (int i = 0; i < _entries.size(); i++) {
      ConstantPoolEntry entry = _entries.get(i);

      if (! (entry instanceof DoubleConstant))
        continue;

      DoubleConstant doubleEntry = (DoubleConstant) entry;

      if (doubleEntry.getValue() == value)
        return doubleEntry;
    }

    return null;
  }
1352660
@CheckForNull
  public Double getDouble(String key) {
    String value = getString(key);
    if (StringUtils.isNotEmpty(value)) {
      try {
        return Double.valueOf(value);
      } catch (NumberFormatException e) {
        throw new IllegalStateException(String.format("The property '%s' is not a double value", key));
      }
    }
    return null;
  }
732885
public static double trim(double value) {
    if (value > MAX_DOUBLE_TO_ROUND || value < -MAX_DOUBLE_TO_ROUND) {
      return value;
    }
    return Math.round(value * ROUND_PRECISION) / ROUND_PRECISION;
  }
384302
private static BigDecimal getBigDecimalOrNull(Object value) {
            if ( !(value instanceof Number || value instanceof String) ) {
                return null;
            }
            if ( !BigDecimal.class.isAssignableFrom( value.getClass() ) ) {
                if ( value instanceof Long || value instanceof Integer || value instanceof Short || value instanceof Byte ||
                     value instanceof AtomicLong || value instanceof AtomicInteger ) {
                    value = new BigDecimal( ((Number) value).longValue(), MathContext.DECIMAL128 );
                } else if ( value instanceof BigInteger ) {
                    value = new BigDecimal( ((BigInteger) value).toString(), MathContext.DECIMAL128 );
                } else if ( value instanceof String ) {
                    // we need to remove leading zeros to prevent octal conversion
                    value = new BigDecimal( ((String) value).replaceFirst("^0+(?!$)", ""), MathContext.DECIMAL128 );
                } else {
                    value = new BigDecimal( ((Number) value).doubleValue(), MathContext.DECIMAL128 );
                }
            }
            return (BigDecimal) value;
        }
427788
public static final Integer getInteger(Number value)
   {
      Integer result = null;
      if (value != null)
      {
         if (value instanceof Integer)
         {
            result = (Integer) value;
         }
         else
         {
            result = Integer.valueOf((int) Math.round(value.doubleValue()));
         }
      }
      return (result);
   }
1363920
public static void negative(Double value) {
		if(!validation) return;
		Validate.notNull(value);
		if(value >= 0.0)
			throw new ParameterException(ErrorCode.NOTNEGATIVE);
	}
894264
@Override
  public synchronized void accept(final double value) {
    super.accept(value);
    final double squareValue = value * value;
    simpleSumOfSquare += squareValue;
    sumOfSquareWithCompensation(squareValue);
  }
1158798
@Nullable
  public Double getDouble(@Nonnull String field) {
    Number number = (Number) get(field);
    return number == null ? null : number.doubleValue();
  }
1232249
private static double doubleValue(Object attributeValue)
         throws NumberFormatException {

        if (attributeValue instanceof Number) {
            return (((Number) attributeValue).doubleValue());
        } else {
            return (Double.parseDouble(attributeValue.toString()));
        }

    }