private static int getRound(double dSource){
int iRound;
BigDecimal deSource = new BigDecimal(dSource);
iRound= deSource.setScale(0,BigDecimal.ROUND_HALF_UP).intValue();
return iRound;
}
public static void main(String[] args) {
try { System.out.println("0.345 : " + getRound(0.345));
System.out.println("0.545 : " + getRound(0.545));
System.out.println("0.945 : " + getRound(0.945));
System.out.println("0.045 : " + getRound(0.045));
}catch (Exception e) {
e.printStackTrace();
}
}