<< All Posts
Format a double number to shows two numbers after comma in JAVA


How to format a double number to shows a decimal number with two numbers after comma? (In JAVA)

import java.text.DecimalFormat;   
DecimalFormat df = new DecimalFormat("#,###.00");
df.format(1234.36);

and you can use this other way:

double x = 123.123;
System.out.printf( "%.2f", x );



<< All Posts

rodolfo.io

🇧🇷 🇨🇦
Runs on OpenBSD 🐡