Allow more currency customization.

Added currency key to messages.
This commit is contained in:
KHobbits 2012-03-04 10:11:58 +00:00
parent c3fa56322b
commit 6da705c86f
17 changed files with 269 additions and 252 deletions

View file

@ -422,11 +422,11 @@ public class Util
}
return is;
}
private static DecimalFormat df = new DecimalFormat("#0.00", DecimalFormatSymbols.getInstance(Locale.US));
private static DecimalFormat dFormat = new DecimalFormat("#0.00", DecimalFormatSymbols.getInstance(Locale.US));
public static String formatCurrency(final double value, final IEssentials ess)
public static String formatAsCurrency(final double value)
{
String str = ess.getSettings().getCurrencySymbol() + df.format(value);
String str = dFormat.format(value);
if (str.endsWith(".00"))
{
str = str.substring(0, str.length() - 3);
@ -434,6 +434,16 @@ public class Util
return str;
}
public static String displayCurrency(final double value, final IEssentials ess)
{
return _("currency", ess.getSettings().getCurrencySymbol(), formatAsCurrency(value));
}
public static String shortCurrency(final double value, final IEssentials ess)
{
return ess.getSettings().getCurrencySymbol() + formatAsCurrency(value);
}
public static double roundDouble(final double d)
{
return Math.round(d * 100.0) / 100.0;