Home » Java Codes

Java Utility Classes – Getting Currency Symbols

6 March 2009 239 views No Comment

This example shows how to get the currency symbols for different countries. The code below displays the currency symbols for three countries, US, UK and France.

package com.javadb.examples;

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


/**
 *
 * *#64;author *#119;*#119;*#119;*#46;java*#100;b.*#99;*#111;*#109;
 */

public class Main {
    
    public void displayCurrencySymbols() {
        
        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());
 
        currency = Currency.getInstance(Locale.FRANCE);
        System.out.println(“France: “ currency.getSymbol());
        
    }
    public static void main(String[] args) {

        new Main().displayCurrencySymbols();
    }
 
 }



The output from the code example:


United States: USD
United Kingdom: GBP
France: €


Tags: , , , , , , , , , , , , , , , , , , , , , , , , , ,

Leave your response!

You can use these tags:
<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>