public static boolean isNumeric(String str) { try { double d = Double.parseDouble(str); } catch(NumberFormatException nfe) { return false; } return true; }
@Override public Double apply(String input) { return Double.parseDouble(input); } };
/** * Constructs a new MutableDouble parsing the given string. * * @param value the string to parse, not null * @throws NumberFormatException if the string cannot be parsed into a double * @since 2.5 */ public MutableDouble(final String value) { super(); this.value = Double.parseDouble(value); }
String text = "12.34"; // example String double value = Double.parseDouble(text);
double total = Double.parseDouble(jlbTotal.getText()); double price = Double.parseDouble(jlbPrice.getText());
/** Returns this value as a double. * @throws IllegalStateException if this an array or object. */ public double asDouble () { switch (type) { case stringValue: return Double.parseDouble(stringValue); case doubleValue: return doubleValue; case longValue: return (double)longValue; case booleanValue: return longValue != 0 ? 1 : 0; } throw new IllegalStateException("Value cannot be converted to double: " + type); }
/** Returns this value as a double. * @throws IllegalStateException if this an array or object. */ public double asDouble () { switch (type) { case stringValue: return Double.parseDouble(stringValue); case doubleValue: return doubleValue; case longValue: return (double)longValue; case booleanValue: return longValue != 0 ? 1 : 0; } throw new IllegalStateException("Value cannot be converted to double: " + type); }
@Override public double convertToDouble(CharSequence value) { if (value instanceof AsciiString) { return ((AsciiString) value).parseDouble(); } return Double.parseDouble(value.toString()); } }
public double parseDouble(int start, int end) { return Double.parseDouble(toString(start, end)); }
public double doubleValue() { return Double.parseDouble(numberString()); }
@Override protected void checkParameters(String attribute, String value) { super.checkParameters(attribute, value); if (PARAM_QUALITY_FACTOR.equals(attribute)) { value = unquote(value); double d = Double.parseDouble(value); Assert.isTrue(d >= 0D && d <= 1D, "Invalid quality value \"" + value + "\": should be between 0.0 and 1.0"); } }
protected double readDoubleValue(long longValue) { int beginIndex = pos - 1; next(); while (ch >= '0' && ch <= '9') { next(); } int endIndex = pos - 1; String text = path.substring(beginIndex, endIndex); double value = Double.parseDouble(text); value += longValue; return value; }
/** * Return the quality factor, as indicated by a {@code q} parameter, if any. * Defaults to {@code 1.0}. * @return the quality factor as double value */ public double getQualityValue() { String qualityFactor = getParameter(PARAM_QUALITY_FACTOR); return (qualityFactor != null ? Double.parseDouble(unquote(qualityFactor)) : 1D); }
@Override public double getDouble(int field) { checkFieldType(field, ImmutableSet.of(DOUBLE)); return Double.parseDouble(getFieldValue(field).toString()); }
public double getParameter(String key, double defaultValue) { Number n = getNumbers().get(key); if (n != null) { return n.doubleValue(); } String value = getParameter(key); if (StringUtils.isEmpty(value)) { return defaultValue; } double d = Double.parseDouble(value); getNumbers().put(key, d); return d; }
public double getParameter(String key, double defaultValue) { Number n = getNumbers().get(key); if (n != null) { return n.doubleValue(); } String value = getParameter(key); if (StringUtils.isEmpty(value)) { return defaultValue; } double d = Double.parseDouble(value); getNumbers().put(key, d); return d; }
public double getMethodParameter(String method, String key, double defaultValue) { String methodKey = method + "." + key; Number n = getNumbers().get(methodKey); if (n != null) { return n.doubleValue(); } String value = getMethodParameter(method, key); if (StringUtils.isEmpty(value)) { return defaultValue; } double d = Double.parseDouble(value); getNumbers().put(methodKey, d); return d; }
public double getMethodParameter(String method, String key, double defaultValue) { String methodKey = method + "." + key; Number n = getNumbers().get(methodKey); if (n != null) { return n.doubleValue(); } String value = getMethodParameter(method, key); if (StringUtils.isEmpty(value)) { return defaultValue; } double d = Double.parseDouble(value); getNumbers().put(methodKey, d); return d; }
private static double parseDouble(Slice slice, int start, int length) throws RcFileCorruptionException { try { return Double.parseDouble(slice.toStringAscii(start, length)); } catch (NumberFormatException e) { throw new RcFileCorruptionException(e, "Invalid double value"); } } }
public static Literal getRealLiteral(String numberToken, int startPos, int endPos, boolean isFloat) { try { if (isFloat) { float value = Float.parseFloat(numberToken); return new FloatLiteral(numberToken, startPos, endPos, value); } else { double value = Double.parseDouble(numberToken); return new RealLiteral(numberToken, startPos, endPos, value); } } catch (NumberFormatException ex) { throw new InternalParseException(new SpelParseException(startPos, ex, SpelMessage.NOT_A_REAL, numberToken)); } }