Use NumberFormat.getCurrencyInstance():
double amt = 123.456;
NumberFormat formatter = NumberFormat.getCurrencyInstance();
System.out.println(formatter.format(amt));
Output:
$123.46
More Related Contents:
- Double decimal formatting in Java
- Force point (“.”) as decimal separator in java
- Retain precision with double in Java
- How do I print a double value without scientific notation using Java?
- Convert java.util.Date to String
- How to print a float with 2 decimal places in Java?
- Moving decimal places over in a double
- How can I convert byte size into a human-readable format in Java?
- Convert float to double without losing precision
- Format double value in scientific notation
- Why doesn’t Java throw an Exception when dividing by 0.0?
- How to print formatted BigDecimal values?
- How can I truncate a double to only two decimal places in Java?
- How can I convert a byte array into a double and back?
- Double calculation producing odd result [duplicate]
- Why converting from float to double changes the value?
- Convert double to BigDecimal and set BigDecimal Precision
- How to cast from List to double[] in Java?
- Sprintf equivalent in Java
- Format a BigDecimal as String with max 2 decimal digits, removing 0 on decimal part
- Why does integer division by zero 1/0 give error but floating point 1/0.0 returns “Inf”?
- Java double precision sum trouble
- Print out elements from an Array with a Comma between the elements
- Why can’t we use ‘==’ to compare two float or double numbers [duplicate]
- Comparator with double type
- Convert Double to Binary representation?
- How to manipulate arrays. Find the average. Beginner Java
- JPanel Padding in Java
- How to round up integer division and have int result in Java? [duplicate]
- Java decimal formatting using String.format?