diff --git a/libreplan-webapp/src/main/java/org/libreplan/web/common/Util.java b/libreplan-webapp/src/main/java/org/libreplan/web/common/Util.java index 013e579bc..953dad693 100644 --- a/libreplan-webapp/src/main/java/org/libreplan/web/common/Util.java +++ b/libreplan-webapp/src/main/java/org/libreplan/web/common/Util.java @@ -24,6 +24,7 @@ package org.libreplan.web.common; import static org.libreplan.web.I18nHelper._; import java.math.BigDecimal; +import java.text.DecimalFormat; import java.util.ArrayList; import java.util.Date; import java.util.Iterator; @@ -65,6 +66,12 @@ public class Util { private static final Log LOG = LogFactory.getLog(Util.class); + /** + * Special chars from {@link DecimalFormat} class. + */ + private static final String[] DECIMAL_FORMAT_SPECIAL_CHARS = { "0", ",", + ".", "\u2030", "%", "#", ";", "-" }; + private Util() { } @@ -656,7 +663,19 @@ public class Util { * symbol */ public static String getMoneyFormat() { - return "###.## " + getCurrencySymbol(); + return "###.## " + escapeDecimalFormatSpecialChars(getCurrencySymbol()); + } + + /** + * Escapes special chars used in {@link DecimalFormat} to define the number + * format that appear in the currencySymbol. + */ + private static String escapeDecimalFormatSpecialChars(String currencySymbol) { + for (String specialChar : DECIMAL_FORMAT_SPECIAL_CHARS) { + currencySymbol = currencySymbol.replace(specialChar, "'" + + specialChar + "'"); + } + return currencySymbol; } }