java.lang.Double.parseDouble()方法的使用及代码示例

x33g5p2x  于2022-01-16 转载在 其他  
字(5.7k)|赞(0)|评价(0)|浏览(400)

本文整理了Java中java.lang.Double.parseDouble()方法的一些代码示例,展示了Double.parseDouble()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Double.parseDouble()方法的具体详情如下:
包路径:java.lang.Double
类名称:Double
方法名:parseDouble

Double.parseDouble介绍

[英]Parses the specified string as a double value.
[中]将指定的字符串解析为双精度值。

代码示例

代码示例来源:origin: stackoverflow.com

public static boolean isNumeric(String str)  
{  
 try  
 {  
  double d = Double.parseDouble(str);  
 }  
 catch(NumberFormatException nfe)  
 {  
  return false;  
 }  
 return true;  
}

代码示例来源:origin: ctripcorp/apollo

@Override
 public Double apply(String input) {
  return Double.parseDouble(input);
 }
};

代码示例来源:origin: org.apache.commons/commons-lang3

/**
 * 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);
}

代码示例来源:origin: stackoverflow.com

String text = "12.34"; // example String
double value = Double.parseDouble(text);

代码示例来源:origin: stackoverflow.com

double total = Double.parseDouble(jlbTotal.getText());
double price = Double.parseDouble(jlbPrice.getText());

代码示例来源:origin: libgdx/libgdx

/** 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);
}

代码示例来源:origin: libgdx/libgdx

/** 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);
}

代码示例来源:origin: netty/netty

@Override
  public double convertToDouble(CharSequence value) {
    if (value instanceof AsciiString) {
      return ((AsciiString) value).parseDouble();
    }
    return Double.parseDouble(value.toString());
  }
}

代码示例来源:origin: netty/netty

public double parseDouble(int start, int end) {
  return Double.parseDouble(toString(start, end));
}

代码示例来源:origin: alibaba/fastjson

public double doubleValue() {
  return Double.parseDouble(numberString());
}

代码示例来源:origin: spring-projects/spring-framework

@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");
  }
}

代码示例来源:origin: alibaba/fastjson

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;
}

代码示例来源:origin: spring-projects/spring-framework

/**
 * 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);
}

代码示例来源:origin: prestodb/presto

@Override
public double getDouble(int field)
{
  checkFieldType(field, ImmutableSet.of(DOUBLE));
  return Double.parseDouble(getFieldValue(field).toString());
}

代码示例来源:origin: apache/incubator-dubbo

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;
}

代码示例来源:origin: apache/incubator-dubbo

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;
}

代码示例来源:origin: apache/incubator-dubbo

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;
}

代码示例来源:origin: apache/incubator-dubbo

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;
}

代码示例来源:origin: prestodb/presto

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");
    }
  }
}

代码示例来源:origin: spring-projects/spring-framework

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));
  }
}

相关文章