Revision 6d6b02e9
Added by Andreas Kohlbecker over 5 years ago
src/main/java/eu/etaxonomy/cdm/vaadin/ui/RegistrationUIDefaults.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.cdm.vaadin.ui; |
10 | 10 |
|
11 |
import java.text.DecimalFormat; |
|
12 |
import java.text.NumberFormat; |
|
11 | 13 |
import java.util.Arrays; |
12 | 14 |
import java.util.EnumSet; |
13 | 15 |
import java.util.List; |
... | ... | |
66 | 68 |
public static final String ERROR_CONTACT_MESSAGE_LINE = "Please contact <a href=\"mailto:editsupport@bgbm.org\">editsupport@bgbm.org</a> for support and more information."; |
67 | 69 |
|
68 | 70 |
public static final List<Role> COLLECTION_EDITOR_SUB_COLLECTION_VISIBILITY_RESTRICTION = Arrays.asList(Role.ROLE_ADMIN, RolesAndPermissions.ROLE_CURATION); |
71 |
|
|
72 |
public static NumberFormat NUMBER_FORMAT_OVERRIDE = new DecimalFormat("#"); |
|
69 | 73 |
} |
src/main/java/eu/etaxonomy/cdm/vaadin/util/converter/IntegerConverter.java | ||
---|---|---|
8 | 8 |
*/ |
9 | 9 |
package eu.etaxonomy.cdm.vaadin.util.converter; |
10 | 10 |
|
11 |
import java.text.DecimalFormatSymbols; |
|
12 | 11 |
import java.text.NumberFormat; |
13 | 12 |
import java.text.ParseException; |
14 | 13 |
import java.util.Locale; |
... | ... | |
17 | 16 |
|
18 | 17 |
import com.vaadin.data.util.converter.Converter; |
19 | 18 |
|
19 |
import eu.etaxonomy.cdm.vaadin.ui.RegistrationUIDefaults; |
|
20 |
|
|
20 | 21 |
/** |
21 | 22 |
* @author a.kohlbecker |
22 | 23 |
* @since Mar 28, 2018 |
... | ... | |
36 | 37 |
if(StringUtils.isBlank(value)){ |
37 | 38 |
return null; |
38 | 39 |
} |
39 |
if(locale == null){ |
|
40 |
locale = Locale.getDefault(); |
|
41 |
} |
|
42 |
DecimalFormatSymbols symbols = DecimalFormatSymbols.getInstance(locale); |
|
43 |
NumberFormat nf = NumberFormat.getNumberInstance(locale); |
|
40 |
NumberFormat nf = numberFormat(locale); |
|
44 | 41 |
try { |
45 | 42 |
return nf.parse(value).intValue(); |
46 | 43 |
} catch (ParseException e){ |
... | ... | |
58 | 55 |
if(value == null){ |
59 | 56 |
return null; |
60 | 57 |
} |
61 |
if(locale == null){ |
|
62 |
locale = Locale.getDefault(); |
|
63 |
} |
|
64 |
NumberFormat nf = NumberFormat.getInstance(locale); |
|
58 |
NumberFormat nf = numberFormat(locale); |
|
65 | 59 |
return nf.format(value); |
66 | 60 |
} |
67 | 61 |
|
62 |
/** |
|
63 |
* @param locale |
|
64 |
* @return |
|
65 |
*/ |
|
66 |
public NumberFormat numberFormat(Locale locale) { |
|
67 |
NumberFormat nf; |
|
68 |
if(RegistrationUIDefaults.NUMBER_FORMAT_OVERRIDE != null){ |
|
69 |
nf = RegistrationUIDefaults.NUMBER_FORMAT_OVERRIDE; |
|
70 |
} else { |
|
71 |
if(locale == null){ |
|
72 |
locale = Locale.getDefault(); |
|
73 |
} |
|
74 |
nf = NumberFormat.getInstance(locale); |
|
75 |
} |
|
76 |
return nf; |
|
77 |
} |
|
78 |
|
|
68 | 79 |
/** |
69 | 80 |
* {@inheritDoc} |
70 | 81 |
*/ |
Also available in: Unified diff
ref #7639 using fixed NumberFormat for integers to avoid locale confusion