IDEMPIERE-3284 Get the proper currency format for a multi-currency, multi-language report

This commit is contained in:
Carlos Ruiz 2017-01-16 23:47:58 +01:00
parent 0525d03dd0
commit 76424a05fb
1 changed files with 18 additions and 0 deletions

View File

@ -58,12 +58,14 @@ import java.text.DateFormat;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.Currency;
import java.util.List;
import java.util.Locale;
import java.util.logging.Level;
import org.adempiere.base.IDisplayTypeFactory;
import org.adempiere.base.Service;
import org.compiere.model.MCurrency;
/**
* System Display Types.
@ -736,4 +738,20 @@ public final class DisplayType
return "UNKNOWN DisplayType=" + displayType;
} // getDescription
/**
* Helper method to get a currency format in a language (multi-currency and multi-language system)
* @param language locale code
* @param currency code
* @return number format
*/
public static NumberFormat getCurrencyFormat(String langcode, String currencyCode)
{
Locale locale = Language.getLocale(langcode);
NumberFormat currencyFormatter = NumberFormat.getCurrencyInstance(locale);
Currency currency = Currency.getInstance(currencyCode);
currencyFormatter.setCurrency(currency);
return currencyFormatter;
} // getCurrencyFormat
} // DisplayType