java round a double number to 2 decimal places

w‮w‬w.lautturi.com
java round a double number to 2 decimal places
/**
 * @author lautturi.com
 * Java example: double to 2 decimal places
 */

public class Lautturi {

	public static void main(String[] args) {

		double value = 3.14159;
		String result = String.format("%.2f", value);
		System.out.println(result);

	}
}

output:

3.14
Created Time:2017-09-22 23:51:58  Author:lautturi