PluginUtils { public static String formatMoney(Decimal input, Locale locale) { double cents = Double.parseDouble(input.toString()); cents /= 100; DecimalFormatSymbols symbols = new DecimalFormatSymbols(locale); DecimalFormat format = new DecimalFormat("#,##0.00", symbols); return format.format(cents); } private  PluginUtils(); static int hexDigitToInt(char ch); static String escapeScriptTags(String str); static void escapeHtml(String str, StringBuilder buf); static void escapeHtmlAttribute(String str, StringBuilder buf); static String formatMoney(Decimal input, Locale locale); static String formatMoney(Decimal amount, String currencyCode, CLDR cldr); static String removeTags(String str); static String slugify(String value); static String truncate(String value, int maxLen, String ellipses); static void leftPad(long value, char padChar, int maxDigits, StringBuilder buf);  }
@Test public void testFormatMoney() { assertEquals(PluginUtils.formatMoney(new Decimal(100), Locale.US), "1.00"); assertEquals(PluginUtils.formatMoney(new Decimal(12345), Locale.US), "123.45"); assertEquals(PluginUtils.formatMoney(new Decimal(12345), Locale.GERMAN), "123,45"); }
@Test public void testFormatMoneyCLDR() { CLDR en = CLDR.get("en-US"); assertEquals(PluginUtils.formatMoney(new Decimal(1), "USD", en), "$1.00"); assertEquals(PluginUtils.formatMoney(new Decimal(123.45), "USD", en), "$123.45"); CLDR de = CLDR.get("de"); assertEquals(PluginUtils.formatMoney(new Decimal(123.45), "USD", de), "123,45 $"); assertEquals(PluginUtils.formatMoney(new Decimal(123.45), "EUR", de), "123,45 €"); }