Submitted by:
Francisco José Peñarrubia fjpATscolab.es to the OOSTethys general list
I have a little problem with Java Toolkit:
java.lang.NumberFormatException: For input string: "36,69623"
at sun.misc.FloatingDecimal.readJavaFormatString(Unknown Source)
at java.lang.Double.parseDouble(Unknown Source)
at org.oostethys.model.impl.ObservationNetcdf.process(ObservationNetcdf.java:503)
at org.oostethys.model.impl.test.ObservationNetcdfTest.testCTDMBARI(ObservationNetcdfTest.java:43)
The problem is about English - Spanish Locale, and the method where it happens is
private String getValueFormatted(Number val) {
DecimalFormat myFormatter = new DecimalFormat();
myFormatter.setMaximumFractionDigits(6);
String output = myFormatter.format(val);
return output;
}
(A double is transformed in String and Java uses (in my machine) Spanish Locale, an instead of 36.69623 I get 36,69623, then, a problem comes with the SOS service)
I think this can solve the problem:
// DecimalFormat myFormatter = new DecimalFormat();
NumberFormat myFormatter = NumberFormat.getInstance(Locale.ENGLISH);
More information about formattin:
http://www.iro.umontreal.ca/~vaucher/Java/tutorials/Formatting.html