java string format double value

java string format double value
‮er‬fer to:lautturi.com
/**
 * @author lautturi.com 
 * Java example: format double value to string with 2 decimal places
 */

import java.util.*;

public class Lautturi {
	public static void main(String[] args) {
		double d = 7.994;
		String str = String.format("%.2f", d);
		System.out.print("Price:$"+str); 
	}
}

output:

Price:.99
Created Time:2017-09-30 18:01:03  Author:lautturi