Here you can find the source of parseInternationalDouble(String number)
Parameter | Description |
---|---|
number | the number with a point or a comma as decimal separator |
Parameter | Description |
---|---|
ParseException | in case of errors |
public static float parseInternationalDouble(String number) throws ParseException
//package com.java2s; import java.text.NumberFormat; import java.text.ParseException; import java.util.Locale; public class Main { /**//w w w . j av a 2 s.co m * parse a string and return the corresponding double value, it accepts * comma or point as decimal separator * * @param number * the number with a point or a comma as decimal separator * @return the float value corresponding to the parsed string * @throws ParseException * in case of errors */ public static float parseInternationalDouble(String number) throws ParseException { NumberFormat nffrench = NumberFormat.getInstance(Locale.FRENCH); NumberFormat nfus = NumberFormat.getInstance(Locale.US); Number numberToReturn = number.indexOf(',') != -1 ? nffrench.parse(number) : nfus.parse(number); return numberToReturn.floatValue(); } }