Java double to string with 2 decimals

www.la‮u‬tturi.com
Java double to string with 2 decimals
/**
 * @author lautturi.com
 * Java example: double to string with 2 decimals in java
 */

public class Lautturi {

	public static void main(String[] args) {

		double d = 3.14159265359;
		System.out.format("double : %.2f", d);
		String str = String.format("%.2f", d);		
		System.out.println("double : " + str );
		
	}
}
Created Time:2017-09-23 09:41:11  Author:lautturi