Share

OOSTethys

Tracker: Bugs

7 Double String transformation and Locales - ID: 2219404
Last Update: Tracker Item Submitted ( luisbermudez )

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:5
03)
at
org.oostethys.model.impl.test.ObservationNetcdfTest.testCTDMBARI(Observatio
nNetcdfTest.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


luisBermudez ( luisbermudez ) - 2008-11-03 19:37

7

Open

None

luisBermudez

java-toolkit

None

Public


Comments




Log in to comment.

No follow-up comments have been posted.

Attached File

No Files Currently Attached

Change

No changes have been made to this artifact.