I want to work with the decimal part of a number, for example 123.332341 I just want to get the ' .332341 ' only with 3 digits after the period, like this: '< em> .332 '
I use DecimalFormat formato = new DecimalFormat(".###");
(which I found on the internet)
I do the test to check the result, and it does not convert from this type of data
a double "modified"
double numero = .332341;
String modificar = formato.format(numero); //debe quedar .332
double nuevo = Double.parseDouble(formato.format(modificar)); //no convierte
System.out.println(nuevo); //nada
How or what other option can I use to achieve the goal of bringing only 3 digits? Error:
Exception en Thread "main" java.lang.NumberFormatException: For input string: ",332"
...
at java.lang.Double.parseDouble(Double.java:538)
at Binario.Binario.main(Binario.java:30)