views:

301

answers:

2

My open-source Android application uses this in an SQL query:

String.format("%f", someDoubleValue);

Unfortunately, in some languages the coma is "," instead of "." and the SQL engine does not like it.

What is the best way to convert a double to a SQL-friendly string on Android?

A: 

My wild guess:

Locale nullLocale = null;
String.format(nullLocale, "%f", someDoubleValue);

I don't have any means to test it now, unfortunately.

Nicolas Raoul
It works, confirmed by two users. I am still open to any better solution. If there is a "standard" or "official" way to deal with this, I would prefer it.
Nicolas Raoul
A: 

Isn't the Java function Double.toString(someDoubleValues) working, or am I misunderstanding you question?

Janusz
It might be as simple as that! I will try as soon as I can.
Nicolas Raoul
I am afraid it is not going to work because when a double it is long enough the toString() method it is going to represent it with an exponential.
Nicolas Raoul