Java tutorial
//package com.java2s; public class Main { public static String distToString(Float dist) { if (dist == null) { return ""; } if (dist > 999) { return String.format("%.2fkm", dist / 1000); } else { return String.format("%dm", dist.intValue()); } } }