You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
new NumberRenderer<>(provider, locale) does not format numbers according to locale #8970
The NumberRenderer(ValueProvider, Locale) constructor ends up using String.format(locale, "%s", value) where %s in the format string is defined to use the value as a Formattable if it implements that interface and otherwise uses toString() on the value. Since e.g. Double or Integer doesn't implement Formattable, the end result is that numbers are formatted using toString() which uses the JVM default locale without taking the provided locale into account. The end result is thus that numbers are not formatted according to the provided locale.
Using the NumberRenderer(ValueProvider, NumberFormat) constructor instead (using e.g.NumberFormat.getInstance(locale) to get a NumberFormat instance) works as exected.
changed the title [-]new NumberFormatter<>(provider, locale) does not format numbers according to locale[/-][+]new NumberRenderer<>(provider, locale) does not format numbers according to locale[/+]on Sep 2, 2020
so it is on the borderline as "the numbers natural string representation in the given locale" is not entirely obvious, but probably one could expect it to try to behave the same as when creating the NumberFormat out of the locale. The javadocs could be clarified then too. But I'll mark this as a bug.
What is the purpose of a NumberRenderer(ValueProvider, Locale) constructor other than to format numbers based on the provided locale?
As it's currently implemented, the locale parameter seems to not have any practical impact at all except in the special case with a value provider that returns a custom Number subtype that also implements Formattable (none of the bulit-in ones do).
I expect that new NumberRenderer<Object>(ignore -> Double.valueOf(1.2), new Locale("fi")) would render values as 1,2 whereas the same with Locale.ENGLISH would render values as 1.2. With the current implementation, both variants format the number according to the JVM's default locale.
Activity
[-]new NumberFormatter<>(provider, locale) does not format numbers according to locale[/-][+]new NumberRenderer<>(provider, locale) does not format numbers according to locale[/+]pleku commentedon Nov 24, 2020
This has been working like this since 1.0 with the javadocs of
so it is on the borderline as "the numbers natural string representation in the given locale" is not entirely obvious, but probably one could expect it to try to behave the same as when creating the
NumberFormatout of the locale. The javadocs could be clarified then too. But I'll mark this as a bug.Legioth commentedon Nov 24, 2020
What is the purpose of a
NumberRenderer(ValueProvider, Locale)constructor other than to format numbers based on the provided locale?As it's currently implemented, the locale parameter seems to not have any practical impact at all except in the special case with a value provider that returns a custom
Numbersubtype that also implementsFormattable(none of the bulit-in ones do).I expect that
new NumberRenderer<Object>(ignore -> Double.valueOf(1.2), new Locale("fi"))would render values as1,2whereas the same withLocale.ENGLISHwould render values as1.2. With the current implementation, both variants format the number according to the JVM's default locale.fix: format numbers in NumberRenderer using Locale if it's provided
fix: format numbers in NumberRenderer using Locale if it's provided (#…
fix: format numbers in NumberRenderer using Locale if it's provided (#…
fix: format numbers in NumberRenderer using Locale if it's provided (#…
fix: format numbers in NumberRenderer using Locale if it's provided (#…
fix: format numbers in NumberRenderer using Locale if it's provided (#…
fix: format numbers in NumberRenderer using Locale if it's provided (#…
fix: format numbers in NumberRenderer using Locale if it's provided (#…
vaadin-bot commentedon Jul 15, 2021
This ticket/PR has been released with platform 14.6.6. For prerelease versions, it will be included in its final version.
vaadin-bot commentedon Jul 26, 2021
This ticket/PR has been released with platform 20.0.5. For prerelease versions, it will be included in its final version.
vaadin-bot commentedon Aug 6, 2021
This ticket/PR has been released with platform 21.0.0.beta1 and is also targeting the upcoming stable 21.0.0 version.
vaadin-bot commentedon Aug 9, 2021
This ticket/PR has been released with platform 14.7.0.alpha3 and is also targeting the upcoming stable 14.7.0 version.