round off to 2 decimal places in java

www.lau‮‬tturi.com
round off to 2 decimal places in java
/**
 * @author lautturi.com 
 * Java example: round off double to 2 decimal places 
 */

import java.util.*;

public class Lautturi {

	public static void main(String[] args) {
		double num = 123.4567;
	    double roundOff = (double)Math.round(num*100)/100;

	    System.out.println(roundOff);

	}
}

output:

123.46
Created Time:2017-10-08 10:09:17  Author:lautturi