Hi,
I have some problems with pattern for Double, for English the next code work:
if (id_depositField.getValue().getHumidity() == null) {
Humidity = "";
} else Humidity = id_depositField.getValue().getHumidity().toString();
dHumidityField.setValue(Humidity);
id_depositField.getValue().getHumidity()
is Double
and
dHumidityField
is a textField
so take from database a float value and I inserted to textFiled.
In database the float values have (.) dot for decimal after covert to string put also dot but when is saved the dot disappear because I used Romania locale where I defined for decimal the comma (,) and for thousand separator the dot (.)
My numbers from 6.5 is take it sometime 65 or 6.5 and saved 65, for example.
I have defined my pattern for Romanian.
integerFormat=#
numberDecimalSeparator=,
numberGroupingSeparator=.
I try to use others method to transfer to string:
if (id_depositField.getValue().getHumidity() == null) {
Humidity = "";
} else Humidity = String.valueOf(id_depositField.getValue().getHumidity());
dHumidityField.setValue(Humidity);
and
if (id_depositField.getValue().getHumidity() == null) {
Humidity = "";
} else Humidity = Double.toString(id_depositField.getValue().getHumidity());
dHumidityField.setValue(Humidity);
but also not work.
I try to define the pattern for double:
doubleFormat=#.##0,00
but after this I got next error:
IllegalArgumentException: Malformed pattern "#.##0,00"
finally I found a solution:
if (id_depositField.getValue().getHumidity() == null) {
Humidity = "";
} else Humidity=numberFormatter.apply(id_depositField.getValue().getHumidity());
dHumidityField.setValue(Humidity);
with this is add correctly to dHumidityField.
But how is necessary to defined the pattern for Double in doubleFormat=