I have a JFormattedTextField
with a NumberFormat
with Locale.US. So the decimal separator is the point and the grouping separator is the comma.
Actually, Number
is just a super class for Double
, so you could use Double.parseDouble(...)
and then auto-unboxing should do the rest.
I would suggest you to use regex and use the match fucntion like this:
matches("\\d+([.,])?")
Also if you will use Integer.parseInt(String)
will throw an exception if it will be parsed or you can use Double.parseDouble(value)