public static String formatCoordinate ( double coordinate , int precision ) { String pattern = "0." + new String ( new char [ precision ] ) . replace ( "\0" , "0" ) ; DecimalFormat df = ( DecimalFormat ) DecimalFormat . getInstance ( Locale . US ) ; df . applyPattern ( pattern ) ; df . setRoundingMode ( RoundingMode . FLOOR ) ; return df . format ( coordinate ) ; }
Allows the specific adjusting of a coordinates precision .