question: public static String formatDistanceBetween ( LatLng point1 , LatLng point2 ) { if ( point1 == null || point2 == null ) { return null ; } NumberFormat numberFormat = NumberFormat . getNumberInstance ( ) ; double distance = Math . round ( SphericalUtil . computeDistanceBetween ( point1 , point2 ) ) ; if ( distance >= 1000 ) { numberFormat . setMaximumFractionDigits ( 1 ) ; return numberFormat . format ( distance / 1000 ) + DISTANCE_KM_POSTFIX ; } return numberFormat . format ( distance ) + DISTANCE_M_POSTFIX ; }
target:  Calculate distance between two LatLng points and format it nicely for display. As this is a sample, it only statically supports metric units. A production app should check locale and support the correct units.