import java.text.NumberFormat; import java.text.ParseException; ... // get an conversion object customised for a particular locale NumberFormat nf = java.text.NumberFormat.getInstance( ); // set whether you want commas (or locale equivalent) inserted nf.setGroupingUsed(true ); // set how many places you want to the right of the decimal. nf.setMinimumFractionDigits( 3 ); nf.setMaximumFractionDigits( 3 ); // set how many places you want to the left of the decimal. nf.setMinimumIntegerDigits( 1 ); nf.setMaximumIntegerDigits( 10 ); // convert from binary to String String s1 = nf.format( 1234L ); // will produce 1,234.000 not 1.234 !! String s2 = nf.format( 1.234D ); // will produce 1.234 // convert from String to binary Number n1 = null; Number n2 = null; try { n1 = nf.parse ( "1,234" ); // will produce a Long 1234L n2 = nf.parse ( "1.234" ); // will produce a Double 1.234D } catch ( ParseException e ) { }