CopyPastehas never been so tasty!

Get currency symbol in java

by anonymous

  • 0
  • 0
  • 0
70 views

Get currency symbol in java

Get currency symbol in java:To get currency symbol in java you will use Currency and locale. Locale are parameters and settings that are used to display  Number format settings , time-date settings, currency settings , paper size settings and other minor settings. Make a class and pass a String as argument. getInstance is the method used in it and it will help to print the currency of other countries e.g. JAPAN, UK and USA  .Here is the code that will help you to get currency symbol in Java: 

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

public class Main {
  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());
  }
}

 This is simple article that will help you to get currency symbol in Java. 

Add A Comment: