Java tutorial
/* 4096.251 parses as 4096.251 and formats as 4,096.251 */ import java.text.NumberFormat; import java.text.ParseException; public class MainClass { public static void main(String[] av) { String input = "4096.251"; NumberFormat defForm = NumberFormat.getInstance(); try { Number d = defForm.parse(input); System.out.println(input + " parses as " + d + " and formats as " + defForm.format(d)); } catch (ParseException pe) { System.err.println(input + "not parseable!"); } } }