It’s very common task in Java to format double to 2 decimal places – usually to format currency. It’s not easy to do correctly, but in this post we’ll show how.
The java.util.Currency class represents a currency. These are the main properties of the class: Currencies are identified by their ISO 4217 currency codes There is never more than one Currency instance for any given currency Get instance of the class using getInstance() methods the class is final and cannot be inherited. The class declaration is: …
java.util.Currency.toString() The method java.util.Currency.toString() overrides Object.toString() and returns the ISO 4217 currency code of this currency.
java.util.Currency.getSymbol() The method java.util.Currency.getSymbol() gets the symbol of this currency for the default DISPLAY locale or ISO 4217 currency code.
java.util.Currency.getSymbol(Locale) The method java.util.Currency.getSymbol(Locale) gets the symbol of this currency for the specified locale or ISO 4217 currency code.
java.util.Currency.getNumericCode() Currencies are identified by their ISO 4217 currency codes. The method java.util.Currency.getNumericCode() returns the ISO 4217 numeric code of this currency.
Java Locale information In this tutorial we’re going to show how to get information from Locale, display it nicely to users and get installed locales in the system.
Java Locale create in different ways In this tutorial we’re going to show how to create Locale using builder, constructors, and factory method for different languages and variants to get localized dates.