You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@myfaces.apache.org by gc...@apache.org on 2012/02/14 00:02:53 UTC
svn commit: r1243728 -
/myfaces/trinidad/branches/1.2.12.6.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/convert/NumberConverter.java
Author: gcrawford
Date: Mon Feb 13 23:02:53 2012
New Revision: 1243728
URL: http://svn.apache.org/viewvc?rev=1243728&view=rev
Log:
TRINIDAD-2144 NumberConverter formatHint does not consider trinidad-config.xml settings for decimal-separator, number-grouping-separator
Thanks to Kentaro
Modified:
myfaces/trinidad/branches/1.2.12.6.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/convert/NumberConverter.java
Modified: myfaces/trinidad/branches/1.2.12.6.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/convert/NumberConverter.java
URL: http://svn.apache.org/viewvc/myfaces/trinidad/branches/1.2.12.6.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/convert/NumberConverter.java?rev=1243728&r1=1243727&r2=1243728&view=diff
==============================================================================
--- myfaces/trinidad/branches/1.2.12.6.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/convert/NumberConverter.java (original)
+++ myfaces/trinidad/branches/1.2.12.6.2-branch/trinidad-api/src/main/java/org/apache/myfaces/trinidad/convert/NumberConverter.java Mon Feb 13 23:02:53 2012
@@ -762,6 +762,31 @@ public class NumberConverter extends jav
if (pattern == null)
return null;
+ RequestContext reqCtx = RequestContext.getCurrentInstance();
+ String type = getType();
+ Locale locale = _getLocale(reqCtx, context);
+ DecimalFormat df = (DecimalFormat) _getNumberFormat(pattern, type, locale, reqCtx);
+ if (dfs == null)
+ {
+ dfs = df.getDecimalFormatSymbols();
+ }
+
+ // If grouping and decimal separator have been customized then
+ // show them in the hint so that it's less confusing for the user.
+ char decSep = dfs.getDecimalSeparator();
+ char groupSep = dfs.getGroupingSeparator();
+
+ char[] patternArr = pattern.toCharArray();
+ for (int i = 0; i < patternArr.length; i++)
+ {
+ char c = patternArr[i];
+ if (c == '\u002E')
+ patternArr[i] = decSep;
+ else if (c == '\u002C')
+ patternArr[i] = groupSep;
+ }
+ pattern = new String(patternArr);
+
// If the pattern contains the generic currency sign 'ยค', replace it with the localized
// currency symbol (if one exists), so that when the pattern is displayed (such as in an error
// message), it is more meaningful to the user.
@@ -774,16 +799,6 @@ public class NumberConverter extends jav
if (idx == -1)
return pattern;
- if (dfs == null)
- {
- String type = getType();
- RequestContext reqCtx = RequestContext.getCurrentInstance();
- Locale locale = _getLocale(reqCtx, context);
- NumberFormat fmt = _getNumberFormat(pattern, type, locale, reqCtx);
- DecimalFormat df = (DecimalFormat) fmt;
- dfs = df.getDecimalFormatSymbols();
- }
-
if (idx + 1 < pattern.length() && pattern.charAt(idx + 1) == '\u00A4')
{
// Matcher.quoteReplacement ensures that the replacement string is properly escaped.