In Java, how can I efficiently change the strips such as 1234.56 and string the same bigdidimals Like $ 1,234.56
I am looking for the following:
string becomes 12345.67 string $ 12,345.67
I am also looking to do this with float and BigDecimal .
is a locale-sensitive phrase that works well:
import java.text.NumberFormat; // Receive Currency Formator for Existing Locate Number Format fmt = NumberFormat.getCurrencyInstance (); Println (fmt.format (120.00)); If your current location is in the US, then println will print $ 120.00
another example:
import java.text.NumberFormat; Import java.util.Locale; Local location = new locale ("n", "uk"); Number format fmt = NumberFormat.getCurrencyInstance (locale); Println (fmt.format (120.00)); It will print: £ 120.00
Comments
Post a Comment