hts.StevenWood.com

[ Last Page ]

Formatting numbers as currency

To do this formatting you must add:

import java.text.*;

Currency formatted for this location (let's assume it's English Canada)

string = NumberFormat.getCurrencyInstance().format(123.45);

// gives $123.45 as it appears in English Canada
// use a variable instead of 123.45

 

Currency formatted for a different location (in Java it's called a locale)

// Format
Locale locale = Locale.GERMANY;
String string = NumberFormat.getCurrencyInstance(locale).format(123.45);
// appears as 123,45 DM

 

[Last Page]
All material on this site is copyright © 1997- by Steven Wood or as credited. All right reserved. Use of this site indicates you agreement with the  terms of use.
Send comments or questions to about this page.
Every attempt has been made to credit work under copyright. If there are any claims that copyright has been missed please contact the .
+SDG+