src/main/java/com/teamunify/i18n/I.java
public static Number currencyStringToNumber(String amount, Number defaultValue) {
    if (amount == null || amount.isEmpty())
      return defaultValue;
    LanguageSetting s = languageProvider.vend();
    NumberFormat fmt = NumberFormat.getCurrencyInstance(s.locale);
    try {
      DecimalFormat d = (DecimalFormat) fmt;
      DecimalFormatSymbols symbols = d.getDecimalFormatSymbols();
      if (d.getNegativePrefix().length() > 0)
        amount = amount.replace(d.getNegativePrefix(), "-").trim();
      if (d.getNegativeSuffix().length() > 0)
        amount = amount.replace(d.getNegativeSuffix(), "").trim();
      if (d.getPositivePrefix().length() > 0)
        amount = amount.replace(d.getPositivePrefix(), "").trim();
      if (d.getPositiveSuffix().length() > 0)
        amount = amount.replace(d.getPositiveSuffix(), "").trim();
      d.setPositivePrefix("");
      d.setPositiveSuffix("");
      d.setNegativePrefix("-");
      d.setNegativeSuffix("");
      // In french, the official grouping separator is a Unicode thin space...convert ASCII spaces to thin
      // spaces keeps input conversion from failing....
      if (symbols.getGroupingSeparator() == '\u00a0')
        amount = amount.replace(" ", "\u00a0");
      return fmt.parse(amount);
    } catch (ParseException e) {
      log.debug("Failed to parse currency: {}", amount, e);
    }
    return defaultValue;
  }
/**
   * Parse the given locale-specific currency string, and return a Number that represents the amount. The Number object
   * then easily allows conversion to primitives or even BigDecimal.
   * <p/>
   * Use preferredCurrencyFormat() to get a help string that indicates the preferred input format for the currency.
   * <p/>
   * <b>This function is quite tolerant of user input</b>, and will accept anything that is "normal" when writing a
   * currency in that locale.
   * <p/>
   * <pre>
   * // locale is en
   * I.currencyStringToNumber(&quot;$1,345.66&quot;, 0); // returns 1345.66
   * I.currencyStringToNumber(&quot;1345.66&quot;, 0); // returns 1345.66
   * // locale is fr
   * I.currencyStringToNumber(&quot;1 345,66&quot;, 0); // returns 1345.66
   * I.currencyStringToNumber(&quot;1345.66 &amp;euro&quot;, 0); // returns 1345.66
   * </pre>
   *
   * @param amount       The string (e.g. 100.34) to be parsed
   * @param defaultValue The Number to return if the parsing fails.
   * @return A Number (e.g. rv.toDouble() == 100.34), or defaultValue if the string isn't understandable.
   */
Parse the given locale-specific currency string, and return a Number that represents the amount. The Number object
then easily allows conversion to primitives or even BigDecimal.

Use preferredCurrencyFormat() to get a help string that indicates the preferred input format for the currency.

This function is quite tolerant of user input, and will accept anything that is "normal" when writing a
currency in that locale.

@param amount       The string  to be parsed
@param defaultValue The Number to return if the parsing fails.
@return A Number  == 100.34), or defaultValue if the string isn't understandable.
Parse the given locale - specific currency string and return a Number that represents the amount . The Number object then easily allows conversion to primitives or even BigDecimal . Use preferredCurrencyFormat () to get a help string that indicates the preferred input format for the currency . This function is quite tolerant of user input and will accept anything that is " normal " when writing a currency in that locale . @param amount The string to be parsed @param defaultValue The Number to return if the parsing fails . @return A Number == 100 . 34 ) or defaultValue if the string isn ' t understandable .
public static Number currencyStringToNumber(String amount, Number defaultValue) {
    if (amount == null || amount.isEmpty())
      return defaultValue;
    LanguageSetting s = languageProvider.vend();
    NumberFormat fmt = NumberFormat.getCurrencyInstance(s.locale);
    try {
      DecimalFormat d = (DecimalFormat) fmt;
      DecimalFormatSymbols symbols = d.getDecimalFormatSymbols();
      if (d.getNegativePrefix().length() > 0)
        amount = amount.replace(d.getNegativePrefix(), "-").trim();
      if (d.getNegativeSuffix().length() > 0)
        amount = amount.replace(d.getNegativeSuffix(), "").trim();
      if (d.getPositivePrefix().length() > 0)
        amount = amount.replace(d.getPositivePrefix(), "").trim();
      if (d.getPositiveSuffix().length() > 0)
        amount = amount.replace(d.getPositiveSuffix(), "").trim();
      d.setPositivePrefix("");
      d.setPositiveSuffix("");
      d.setNegativePrefix("-");
      d.setNegativeSuffix("");
      if (symbols.getGroupingSeparator() == '\u00a0')
        amount = amount.replace(" ", "\u00a0");
      return fmt.parse(amount);
    } catch (ParseException e) {
      log.debug("Failed to parse currency: {}", amount, e);
    }
    return defaultValue;
  }
public static Number currencyStringToNumber ( String amount , Number defaultValue ) { if ( amount == null || amount . isEmpty ( ) ) return defaultValue ; LanguageSetting s = languageProvider . vend ( ) ; NumberFormat fmt = NumberFormat . getCurrencyInstance ( s . locale ) ; try { DecimalFormat d = ( DecimalFormat ) fmt ; DecimalFormatSymbols symbols = d . getDecimalFormatSymbols ( ) ; if ( d . getNegativePrefix ( ) . length ( ) > 0 ) amount = amount . replace ( d . getNegativePrefix ( ) , "-" ) . trim ( ) ; if ( d . getNegativeSuffix ( ) . length ( ) > 0 ) amount = amount . replace ( d . getNegativeSuffix ( ) , "" ) . trim ( ) ; if ( d . getPositivePrefix ( ) . length ( ) > 0 ) amount = amount . replace ( d . getPositivePrefix ( ) , "" ) . trim ( ) ; if ( d . getPositiveSuffix ( ) . length ( ) > 0 ) amount = amount . replace ( d . getPositiveSuffix ( ) , "" ) . trim ( ) ; d . setPositivePrefix ( "" ) ; d . setPositiveSuffix ( "" ) ; d . setNegativePrefix ( "-" ) ; d . setNegativeSuffix ( "" ) ; if ( symbols . getGroupingSeparator ( ) == '\u00a0' ) amount = amount . replace ( " " , "\u00a0" ) ; return fmt . parse ( amount ) ; } catch ( ParseException e ) { log . debug ( "Failed to parse currency: {}" , amount , e ) ; } return defaultValue ; }
Parse the given locale-specific currency string, and return a Number that represents the amount.
Parse the given locale - specific currency string and return a Number that represents the amount .
// In french, the official grouping separator is a Unicode thin space...convert ASCII spaces to thin // spaces keeps input conversion from failing....