NumberParserUtils { public static double parseDouble(String value) { return parseDouble(TextUtils.isEmpty(value) ? "0" : value, 0.0D); } private  NumberParserUtils(); static long parseLong(double value); static long parseLong(String value); static long parseLong(String value, long defaultValue); static double parseDouble(String value); static double parseDouble(String value, double defaultValue); static float parseFloat(String value); static float parseFloat(String value, float defaultValue); static int parseInt(String value); static int parseInt(String value, int defaultValue); static int parseInt(Object object); static double parseDouble(Object object); static String parseDoubleToPrettyNumber(double value); static String parseStringWithoutTwoDecimals(String value); static String parseStringWithoutTwoDecimalsToInt(String value); static String parseStringWithFractionDigits(String value, int fractionDigits); static String getPrettyNumber(String number); static String getPrettyBalance(String balance); static String getPrettyBalance(double balance); static String getPrettyDetailBalance(double balance); static String getPrettyNumber(double value, int maxDigit); static String getPrettyNumber(double value, int maxDigit, int roundingMode); static String getPrettyNumber(String value, int maxDigit); static String getPrettyBalance(String value, int maxDigit);  }
@Test public void parseDouble(){ double resultValue = 0; String value ="10.648798787987979"; resultValue = Double.parseDouble(value); Log.d("======", "得到结果result---------->" + new BigDecimal(resultValue)); Log.d("======", "得到结果result---------->" + resultValue); }
@Test public void test(){ String value10 = "10000000000000000000"; String value100 = "100000000000000000000"; String value100000 = "100000000000000000000000"; String value1000000 = "1000000000000000000000000"; Double result10 = NumberParserUtils.parseDouble(value10); Double result100 = NumberParserUtils.parseDouble(value100); Double result100000 = NumberParserUtils.parseDouble(value100000); Double result1000000 = NumberParserUtils.parseDouble(value1000000); System.out.println("---result10:" + result10); System.out.println("---result100:" + result100); System.out.println("---result100000:" + result100000); System.out.println("---result1000000:" + result1000000); }