7
I’m having the following difficulty, picking up a value through my form:
Double salario = Double.parseDouble(request.getParameter("salario"));
Since the value typed by the user will be something like: 2.687,35. And this value, I will compare with some other variables double
also.
However, Double.parseDouble
this method expects the data to be in American format and without thousand separators.
So I used the NumberFormat
as follows:
String salario = request.getParameter("salario");
NumberFormat nf = NumberFormat.getCurrencyInstance(new Locale("pt","BR"));
Double s = nf.parse(salario).doubleValue();
On the line:
Double s = nf.parse(salario).doubleValue();
From The Following Mistake:
unreported exception exception must be caught or declared to be thrown
I’ve tried to put inside the try/catch
and continues with the same message.
could show your code with the
try-catch
?– Math
It looks like this: Double s; //Try { s = nf.parse(salary). doubleValue(); } catch (Parseexception ex) { ex.printStackTrace(); }
– Lucas Olivier