Shaaf’s Blog
msgbartop
Another bit in the wall
msgbarbottom

12 Nov 08 Doing the Locale – Danmark

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

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

Tags: , , , , , , , ,