/** * <p>Convert a <code>String</code> to a <code>double</code>, returning * <code>0.0d</code> if the conversion fails.</p> * * <p>If the string <code>str</code> is <code>null</code>, * <code>0.0d</code> is returned.</p> * * <pre> * NumberUtils.toDouble(null) = 0.0d * NumberUtils.toDouble("") = 0.0d * NumberUtils.toDouble("1.5") = 1.5d * </pre> * * @param str the string to convert, may be <code>null</code> * @return the double represented by the string, or <code>0.0d</code> * if conversion fails * @since 2.1 */ public static double toDouble(String str) { return toDouble(str, 0.0d); }
@Override Double parse(String s) { return StringUtils.isBlank(s) ? null : NumberUtils.toDouble(s); } }
public static double getDouble( Object obj ) { if ( obj instanceof Double ) { return ( Double ) obj; } if ( obj instanceof Number ) { return ( ( Number ) obj ).doubleValue(); } if ( obj instanceof String ) { return NumberUtils.toDouble( ( String ) obj ); } if ( obj instanceof Date ) { return ( ( Date ) obj ).getTime(); } if ( obj instanceof byte[] ) { return getDouble( ( byte[] ) obj ); } if ( obj instanceof ByteBuffer ) { return getDouble( ( ByteBuffer ) obj ); } return 0; }
public static double getDouble( Object obj ) { if ( obj instanceof Double ) { return ( Double ) obj; } if ( obj instanceof Number ) { return ( ( Number ) obj ).doubleValue(); } if ( obj instanceof String ) { return NumberUtils.toDouble( ( String ) obj ); } if ( obj instanceof Date ) { return ( ( Date ) obj ).getTime(); } if ( obj instanceof byte[] ) { return getDouble( ( byte[] ) obj ); } if ( obj instanceof ByteBuffer ) { return getDouble( ( ByteBuffer ) obj ); } return 0; }
/** * Get the parameter passed by controller. When it's executed in the * validation mode, always returns the given default value 0. * * @return param. 0 if the param was not provided. * @since 3.2.3 */ public static double getParamDouble() { return NumberUtils.toDouble(getParam("0"), 0); }
/** * Converts a text value to a double. * * @param text Value to convert. * @return The result of the conversion. */ public static double toDouble(String text) { return NumberUtils.toDouble(text); }
/** * Converts a text value to a double. * * @param text Value to convert. * @return The result of the conversion. */ public static double toDouble(String text) { return NumberUtils.toDouble(text); }
/** * <p>Convert a <code>String</code> to a <code>double</code>, returning * <code>0.0d</code> if the conversion fails.</p> * * <p>If the string <code>str</code> is <code>null</code>, * <code>0.0d</code> is returned.</p> * * <pre> * NumberUtils.toDouble(null) = 0.0d * NumberUtils.toDouble("") = 0.0d * NumberUtils.toDouble("1.5") = 1.5d * </pre> * * @param str the string to convert, may be <code>null</code> * @return the double represented by the string, or <code>0.0d</code> * if conversion fails * @since 2.1 */ public static double toDouble(String str) { return toDouble(str, 0.0d); }
/** * <p>Convert a <code>String</code> to a <code>double</code>, returning * <code>0.0d</code> if the conversion fails.</p> * * <p>If the string <code>str</code> is <code>null</code>, * <code>0.0d</code> is returned.</p> * * <pre> * NumberUtils.toDouble(null) = 0.0d * NumberUtils.toDouble("") = 0.0d * NumberUtils.toDouble("1.5") = 1.5d * </pre> * * @param str the string to convert, may be <code>null</code> * @return the double represented by the string, or <code>0.0d</code> * if conversion fails * @since 2.1 */ public static double toDouble(String str) { return toDouble(str, 0.0d); }
/** * <p>Convert a <code>String</code> to a <code>double</code>, returning * <code>0.0d</code> if the conversion fails.</p> * * <p>If the string <code>str</code> is <code>null</code>, * <code>0.0d</code> is returned.</p> * * <pre> * NumberUtils.toDouble(null) = 0.0d * NumberUtils.toDouble("") = 0.0d * NumberUtils.toDouble("1.5") = 1.5d * </pre> * * @param str the string to convert, may be <code>null</code> * @return the double represented by the string, or <code>0.0d</code> * if conversion fails * @since 2.1 */ public static double toDouble(String str) { return toDouble(str, 0.0d); }
/** * <p>Convert a <code>String</code> to a <code>double</code>, returning * <code>0.0d</code> if the conversion fails.</p> * * <p>If the string <code>str</code> is <code>null</code>, * <code>0.0d</code> is returned.</p> * * <pre> * NumberUtils.toDouble(null) = 0.0d * NumberUtils.toDouble("") = 0.0d * NumberUtils.toDouble("1.5") = 1.5d * </pre> * * @param str the string to convert, may be <code>null</code> * @return the double represented by the string, or <code>0.0d</code> * if conversion fails * @since 2.1 */ public static double toDouble(String str) { return toDouble(str, 0.0d); }
/** * <p>Convert a <code>String</code> to a <code>double</code>, returning * <code>0.0d</code> if the conversion fails.</p> * * <p>If the string <code>str</code> is <code>null</code>, * <code>0.0d</code> is returned.</p> * * <pre> * NumberUtils.toDouble(null) = 0.0d * NumberUtils.toDouble("") = 0.0d * NumberUtils.toDouble("1.5") = 1.5d * </pre> * * @param str the string to convert, may be <code>null</code> * @return the double represented by the string, or <code>0.0d</code> * if conversion fails * @since 2.1 */ public static double toDouble(String str) { return toDouble(str, 0.0d); }
@Override Double parse(String s) { return StringUtils.isBlank(s) ? null : NumberUtils.toDouble(s); } }
/** * Parse a number, passed as String, and return his closest rounding as a long (or 0L if parse fails) * @param value the string to parse * @return the closest long to the parsed double, or <code>0L</code> if parse fails * @see {@link Math#round(double)} */ public static Long toRoundedLong(String value) { double doubleValue = NumberUtils.toDouble(value); if (doubleValue != 0.0d) { return Math.round(doubleValue); } return 0L; }
/** * Parse a double, passed as String, and return his ceil as a long (or 0L if parse fails) * @param value the string to parse * @return the parsed double's floor as a long, or <code>0L</code> if parse fails * @see {@link Math#ceil(double)} */ public static Long toCeilLong(String value) { double doubleValue = NumberUtils.toDouble(value); if (doubleValue != 0.0d) { return Math.round(Math.ceil(doubleValue)); } return 0L; }
/** * Parse a double, passed as String, and return his floor as a long (or 0L if parse fails) * @param value the string to parse * @return the parsed double's floor as a long, or <code>0L</code> if parse fails * @see {@link Math#floor(double)} */ public static Long toFloorLong(String value) { double doubleValue = NumberUtils.toDouble(value); if (doubleValue != 0.0d) { return Math.round(Math.floor(doubleValue)); } return 0L; }
/** * Returns the object located in the specified row in the specified column as a {@link Double}. * * @param rowIndex * the row index * @param columnIndex * the column index * @return the object of at the specified location as a {@link Double}. If the object in * specified row and column is already a Double, returns that object. Otherwise tries to * transform the object to double if it's a number. Finally returns Double.NaN if the * object in specified row and column is not a number. */ public Double getDouble(int rowIndex, int columnIndex) { Object object = get(rowIndex, columnIndex); // if it's double already avoid any transformation if (object instanceof Double) { return (Double) object; } // otherwise use NumberUtils String value = object.toString(); if (NumberUtils.isNumber(value)) { return NumberUtils.toDouble(value); } else { return Double.NaN; } } }
private void syncInputs() { boolean ignore = radNo.isChecked(); record.setIndicated(radYes.isChecked()); record.setGoalRange(ignore ? null : cboGoal.getText()); record.setGoalMin(ignore ? null : NumberUtils.toDouble(cboMin.getText())); record.setGoalMax(ignore ? null : NumberUtils.toDouble(cboMax.getText())); record.setDuration(ignore ? null : cboDuration.getText()); record.setStartDate(ignore ? null : datStart.getValue()); record.setComment(txtComment.getText()); record.setProvider((Practitioner) wbProvider.getSelectedData()); }
Attribute numLinksAttr = elem.getAttribute(TOTAL_LINKS); if (linkScoreAttr != null && numLinksAttr != null) { double linkScore = NumberUtils.toDouble(linkScoreAttr.getValue()); double numLinks = NumberUtils.toInt(numLinksAttr.getValue()); if (numLinks >= 3 && linkScore > 0.60) {