How do I override Currency symbols in Java?
Posted
by edgydruid
on Stack Overflow
See other posts from Stack Overflow
or by edgydruid
Published on 2009-05-21T17:55:27Z
Indexed on
2010/05/21
5:10 UTC
Read the original article
Hit count: 377
I'm trying to print prices in Turkish Liras (ISO 4217 currency code TRY) with Java.
When I do
Currency curr = Currency.getInstance("TRY");
Locale trLocale = new Locale("tr", "TR");
System.out.println(curr.getSymbol(trLocale));
the output is: "YTL".
However, the currency symbol for Turkish Lira has recently changed from "YTL" to "TL" (as can be seen on the Wikipedia page for Turkish Lira). Formatting with NumberFormat
gives a similar result.
I really don't want to write yet another Currency class, especially when Java has one built-in.
Is there a way to override Java's default currency symbol for TRY to "TL"?
© Stack Overflow or respective owner