We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
Java Currency Formatter
Java Currency Formatter
Sort by
recency
|
836 Discussions
|
Please Login in order to post a comment
NumberFormat num1 = NumberFormat.getCurrencyInstance(Locale.US); String us = num1.format(payment); NumberFormat num2 = NumberFormat.getCurrencyInstance(new Locale("en","IN")); String india = num2.format(payment); NumberFormat num3 = NumberFormat.getCurrencyInstance(Locale.CHINA); String china = num3.format(payment); NumberFormat num4 = NumberFormat.getCurrencyInstance(Locale.FRANCE); String france = num4.format(payment);
Java 8 - Not optimal, but hopefully clear:
i use Java 7 and it runs, i expect was helping
import java.util.Locale; import java.text.NumberFormat; import java.util.Scanner;
public class Solution {
}
//Indian rupee Rs.1... was causing problem because my code was writing in hindi characters // at first. And second, third, etc. times as well //The next problem, when I thought I found the solution: //Error: I used a non-ASCII character ("₹") - Headshot, thanks Java8 //Finally there is a working solution (I got help from a smarter one, thx for him). I didn't know it "currInr.startsWith" //I hope I could help if someone would have need it
import java.util.; import java.text.; import java.math.*;
public class Solution {
}
If you are having problems using java 15 in this problem switch to java 7. It worked for me that way.