Here you can find the source of tryParseDoubleValue(String s, double[] result)
Parameter | Description |
---|---|
s | the string value |
result | the result wrapped as an array of integers |
public static boolean tryParseDoubleValue(String s, double[] result)
//package com.java2s; //License from project: Apache License import java.text.NumberFormat; import java.text.ParsePosition; public class Main { /**/*from w w w . jav a 2s . c om*/ * Try parse integer value from a string value * * @param s the string value * @param result the result wrapped as an array of integers * @return true, if successful */ public static boolean tryParseDoubleValue(String s, double[] result) { NumberFormat format = NumberFormat.getNumberInstance(); ParsePosition position = new ParsePosition(0); Object parsedValue = format.parseObject(s, position); if (position.getErrorIndex() > -1) { return false; } if (position.getIndex() < s.length()) { return false; } if (parsedValue instanceof Double) { result[0] = ((Double) parsedValue).doubleValue(); } else if (parsedValue instanceof Long) { result[0] = ((Long) parsedValue).doubleValue(); } return true; } }