List of usage examples for java.util Currency getSymbol
public String getSymbol()
From source file:Main.java
public static void main(String[] args) { Currency currency = Currency.getInstance(Locale.FRANCE); System.out.println("France: " + currency.getSymbol()); }
From source file:Main.java
public static void main(String[] args) { Currency currency = Currency.getInstance(Locale.US); System.out.println("United States: " + currency.getSymbol()); }
From source file:Main.java
public static void main(String[] args) { Currency currency = Currency.getInstance(Locale.UK); System.out.println("United Kingdom: " + currency.getSymbol()); }
From source file:Main.java
public static void main(String[] args) { Currency currency = Currency.getInstance(Locale.US); System.out.println("United States: " + currency.getSymbol()); currency = Currency.getInstance(Locale.UK); System.out.println("United Kingdom: " + currency.getSymbol()); }
From source file:MainClass.java
public static void main(String args[]) { Currency c; c = Currency.getInstance(Locale.US); System.out.println("Symbol: " + c.getSymbol()); System.out.println("Default fractional digits: " + c.getDefaultFractionDigits()); }
From source file:Main.java
public static void main(String[] args) { Currency currency = Currency.getInstance(Locale.JAPAN); System.out.println("Currency.getSymbol() = " + currency.getSymbol()); currency = Currency.getInstance(Locale.UK); System.out.println("Currency.getSymbol() = " + currency.getSymbol()); currency = Currency.getInstance(Locale.US); System.out.println("Currency.getSymbol() = " + currency.getSymbol()); currency = Currency.getInstance(new Locale("in", "ID")); System.out.println("Currency.getSymbol() = " + currency.getSymbol()); }
From source file:Main.java
public static void main(String args[]) { // create a currency for euro Currency curr = Currency.getInstance("EUR"); // get and print the symbol of the currency System.out.println("Currency symbol is = " + curr.getSymbol()); }
From source file:de.jfachwert.bank.Waehrung.java
private static boolean matchesCurrency(String name, Currency c) { return name.equalsIgnoreCase(c.getCurrencyCode()) || name.equalsIgnoreCase(c.getSymbol()); }
From source file:de.ub0r.android.callmeter.ui.prefs.Preferences.java
/** * Get the currency symbol from {@link SharedPreferences}. * //from w ww . j a va 2s .c o m * @param context * {@link Context} * @return currency symbol */ public static final String getCurrencySymbol(final Context context) { final SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(context); final String pcs = p.getString(PREFS_CURRENCY_SYMBOL, ""); if (pcs.length() == 0) { if (defaultCurrencySymbol == null) { try { final Currency cur = Currency.getInstance(Locale.getDefault()); defaultCurrencySymbol = cur.getSymbol(); defaultCurrencyDigits = cur.getDefaultFractionDigits(); } catch (IllegalArgumentException e) { Log.e(TAG, "error getting currency", e); defaultCurrencySymbol = "$"; defaultCurrencyDigits = 2; } } return defaultCurrencySymbol; } else { return pcs; } }
From source file:de.ub0r.android.callmeter.ui.prefs.Preferences.java
/** * Get the currency format from {@link SharedPreferences}. * /*from w w w. jav a 2 s. co m*/ * @param context * {@link Context} * @return currency format */ public static final String getCurrencyFormat(final Context context) { final SharedPreferences p = PreferenceManager.getDefaultSharedPreferences(context); final String pcs = p.getString(PREFS_CURRENCY_FORMAT, ""); if (pcs.length() == 0) { if (defaultCurrencySymbol == null) { try { final Currency cur = Currency.getInstance(Locale.getDefault()); defaultCurrencySymbol = cur.getSymbol(); defaultCurrencyDigits = cur.getDefaultFractionDigits(); } catch (IllegalArgumentException e) { Log.e(TAG, "error getting currency", e); defaultCurrencySymbol = "$"; defaultCurrencyDigits = 2; } } return "%." + defaultCurrencyDigits + "f" + getCurrencySymbol(context); } else { Log.d(TAG, "custom currency format: " + pcs); String c = getCurrencySymbol(context); Log.d(TAG, "custom currency symbol: " + c); if (c.equals("$")) { c = "\\$"; Log.d(TAG, "custom currency symbol: " + c); } else if (c.equals("%")) { c = "%%"; Log.d(TAG, "custom currency symbol: " + c); } final String ret = pcs.replaceAll("\\$", c).replaceAll("\u20AC", c).replaceAll("\u0440", c); Log.d(TAG, "custom currency format: " + ret); return ret; } }