question: public static String parseIntToMetricSuffix ( int x ) { String xint = String . valueOf ( x ) ; if ( xint . endsWith ( "000000" ) ) { xint = xint . replaceAll ( "000000$" , "M" ) ; } else if ( xint . endsWith ( "000" ) ) { xint = xint . replaceAll ( "000$" , "k" ) ; } return xint ; }
target:  Convert 000 and 000,000 to k and M suffix. E.g. 1000 -> "1k"; 123000000 -> 123M See also roundToSignificantFigures() to round numbers.  