Java tutorial
//package com.java2s; import java.math.BigDecimal; public class Main { public static String conversionDistanse(int aDistanceMeter) { return (aDistanceMeter >= 1000) ? Math.round((new BigDecimal(String.valueOf(aDistanceMeter / 1000)) .setScale(1, BigDecimal.ROUND_HALF_UP).longValue())) + "km" : aDistanceMeter + "m"; } }