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
|
861 Discussions
|
Please Login in order to post a comment
I really had a hard time solving this problem, really. In the end the simple solution was changing java 15 jdk for jdk8 or jdk7. (:
Locale us = Locale.US; Locale india = new Locale("en", "IN"); Locale china = Locale.CHINA; Locale france = Locale.FRANCE;
String usFormatted = NumberFormat.getCurrencyInstance(us).format(payment); String indiaFormatted = NumberFormat.getCurrencyInstance(india).format(payment); String chinaFormatted = NumberFormat.getCurrencyInstance(china).format(payment); String franceFormatted = NumberFormat.getCurrencyInstance(france).format(payment); System.out.println("US: " + usFormatted); System.out.println("India: " + indiaFormatted); System.out.println("China: " + chinaFormatted); System.out.println("France: " + franceFormatted);
Here is Java Currency Formatter solution - https://programmingoneonone.com/hackerrank-java-currency-formatter-problem-solution.html
Can't pass the tests due to an ascii code "ï¿¥" in expected results
This is a great exercise to practice working with NumberFormat and Locale in Java. It's interesting to see how currency formatting differs across countries. Cricbet99 Login