This language bar is your friend. Select your favorite languages!
Edit summary for version 11 :

Version 10

Version 11

Idiom #65 Format decimal number

From real value x in [0,1], create its percentage string representation s with one digit after decimal point. E.g. 0.15625 -> "15.6%"

Idiom #65 Format decimal number

From real value x in [0,1], create its percentage string representation s with one digit after decimal point. E.g. 0.15625 -> "15.6%"

Imports
import java.text.DecimalFormat;
Imports
import java.text.DecimalFormat;
Code
String s = new DecimalFormat("0.0%").format(x);
Code
String s = new DecimalFormat("0.0%").format(x);
Comments bubble
This notation handles the multiplication by 100 for you.
Comments bubble
This notation handles the multiplication by 100 for you.
Doc URL
http://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html
Origin
http://docs.oracle.com/javase/7/docs/api/java/text/DecimalFormat.html
Demo URL
https://ideone.com/acD3dm
Demo URL
https://ideone.com/acD3dm