![]() |
The NumberFormat and DecimalFromat class in Java offers a method for formatting numbers based on a location. We can define the formatting cultural conventions, such as the grouping separator, decimal separator, and currency symbol, using the locale parameter. In Java, the NumberFormat class is used for currency formatting. To format numbers as currency, we need to follow these steps:
Program to Convert a String to a Currency Format in JavaThere are certain approaches to convert string to a currency format in Java mentioned below: Method 1: Using NumberFormatJava
Output
INR Currency: ₹10,000.58 USD Currency: $10,000.58 EUR Currency: €10,000.58 Explanation of the Program:
Method 2: Using DecimalFormatJava
Output
Currency: $10,000.58 Explanation of the Program:
|
Reffered: https://www.geeksforgeeks.org
Java |
Type: | Geek |
Category: | Coding |
Sub Category: | Tutorial |
Uploaded by: | Admin |
Views: | 14 |