ADDITIONAL SYSTEM INFORMATION :
Windows 10, Java 12
A DESCRIPTION OF THE PROBLEM :
The default constructor of javafx.util.converter.NumberStringConverter use the default locale returned by Locale.getDefault(). If the format locale (returned by Locale.getDefault(Category.FORMAT)) is different formatting in the application is not consistent as E.g. a default NumberFormat uses the format locale as shown below in the default factory method:
public final static NumberFormat getNumberInstance() {
return getInstance(Locale.getDefault(Locale.Category.FORMAT), NUMBERSTYLE);
}
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Set the format locale different from the default locale:
Locale.setDefault(Locale.US);
Locale.setDefault(Category.FORMAT, Locale.GERMANY);
This will be the case when you have a English language Windows and set the regional formatting settings to something different.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Using a NumberFormat and a NumberStringConverter created with the default factory method/constructor should result in consistent formatting.
ACTUAL -
Using a NumberFormat and a NumberStringConverter created with the default factory method/constructor might result in different output for the same value.
---------- BEGIN SOURCE ----------
import java.text.NumberFormat;
import java.util.Locale;
import java.util.Locale.Category;
import javafx.util.converter.DoubleStringConverter;
public class Test
{
public static void main(String[] args)
{
Locale.setDefault(Locale.US);
Locale.setDefault(Category.FORMAT, Locale.GERMANY);
System.out.println(NumberFormat.getInstance().format(1.234d));
System.out.println(new DoubleStringConverter().toString(1.234d));
}
}
---------- END SOURCE ----------
Windows 10, Java 12
A DESCRIPTION OF THE PROBLEM :
The default constructor of javafx.util.converter.NumberStringConverter use the default locale returned by Locale.getDefault(). If the format locale (returned by Locale.getDefault(Category.FORMAT)) is different formatting in the application is not consistent as E.g. a default NumberFormat uses the format locale as shown below in the default factory method:
public final static NumberFormat getNumberInstance() {
return getInstance(Locale.getDefault(Locale.Category.FORMAT), NUMBERSTYLE);
}
STEPS TO FOLLOW TO REPRODUCE THE PROBLEM :
Set the format locale different from the default locale:
Locale.setDefault(Locale.US);
Locale.setDefault(Category.FORMAT, Locale.GERMANY);
This will be the case when you have a English language Windows and set the regional formatting settings to something different.
EXPECTED VERSUS ACTUAL BEHAVIOR :
EXPECTED -
Using a NumberFormat and a NumberStringConverter created with the default factory method/constructor should result in consistent formatting.
ACTUAL -
Using a NumberFormat and a NumberStringConverter created with the default factory method/constructor might result in different output for the same value.
---------- BEGIN SOURCE ----------
import java.text.NumberFormat;
import java.util.Locale;
import java.util.Locale.Category;
import javafx.util.converter.DoubleStringConverter;
public class Test
{
public static void main(String[] args)
{
Locale.setDefault(Locale.US);
Locale.setDefault(Category.FORMAT, Locale.GERMANY);
System.out.println(NumberFormat.getInstance().format(1.234d));
System.out.println(new DoubleStringConverter().toString(1.234d));
}
}
---------- END SOURCE ----------