Java tutorial
//package com.java2s; import java.text.DecimalFormat; public class Main { private static DecimalFormat df = new DecimalFormat("#.###"); public static double formatDouble(double raw) { String res = df.format(raw).replaceAll(",", "."); return Double.parseDouble(res); } }