import java.util.Date; import java.text.DecimalFormat; public class Test { public static void main(String[] args)throws Exception { double a=1234.5678; String abc=returnWithLeadingZeroes(a); System.out.println(abc); } private String returnWithLeadingZeroes(double d) { DecimalFormat twoDForm = new DecimalFormat("#.##") return twoDForm.format(d); } }