Java Currency.getSymbol() Method

 Posted On  | Yashwant Chavan 

In this tutorial, You will learn about Java Currency.getSymbol() Method. This method returns the symbol of this currency for the default DISPLAY locale. For example, for the US Dollar, the symbol is "$" if the default locale is the US, while for other locales it may be "US$". If no symbol can be determined, the ISO 4217 currency code is returned.

syntax

Gets the symbol of this currency for the default locale.

String java.util.Currency.getSymbol()

Return

return the symbol of this currency for the default locale.

Java Currency.getSymbol() example

Refer below steps

  • Create Currency instance using Currency.getInstance(Locale locale) method.
  • Currency.getSymbol() return the symbol of this currency for the default DISPLAY locale.
package com.technicalkeeda.app;

import java.util.Currency;
import java.util.Locale;

public class JavaCurrencySymbol {

    public static void main(String[] args) {

        Currency us = Currency.getInstance(Locale.US);
        System.out.println("Currency Symbol:- " + us.getSymbol());

        Currency uk = Currency.getInstance(Locale.UK);
        System.out.println("Currency Symbol:- " + uk.getSymbol());

        Currency germany = Currency.getInstance(Locale.GERMANY);
        System.out.println("Currency Symbol:- " + germany.getSymbol());

    }
}

Output

Currency Symbol:- USD
Currency Symbol:- GBP
Currency Symbol:- EUR


© technicalkeeda.com 2017

 |  Find us on Google+ |  Rss Feed

Loaded in 0.0326 seconds.