Doing the Locale – Danmark

The following illustrates how to get the Number format working with a danish locale.

  1. import java.text.NumberFormat;
  2. import java.util.Currency;
  3. import java.util.Locale;
  4.  
  5.  
  6. public class TestLocale {
  7.  
  8.  public static void main(String args[]){
  9.  // Create a Locale for Danmark
  10.  Locale DANMARK = new Locale("da","DK");
  11.  
  12.  // get the currency instance for this locale.
  13.  Currency krone = Currency.getInstance(DANMARK);
  14.  
  15.  // Get a Number format for the locale.
  16.  NumberFormat krFormat = NumberFormat.getCurrencyInstance(DANMARK);
  17.  // A symbol for the currency
  18.  String symbol = krFormat.getCurrency().getSymbol();
  19.  // A double amount
  20.  double amount = 10000.25;
  21. // print it out after formatting.
  22.  System.out.println(krFormat.format(amount));
  23.  }
  24. }

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes:

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre lang="" line="" escaped="" cssfile="">