Java tutorial
//package com.java2s; //License from project: Apache License public class Main { public static String formatNumber2Thousand(int num) { if (num / 1000 <= 0) return String.valueOf(num); return append(String.format("%.1f", (float) num / 1000f), "k"); } public static String append(CharSequence... arr) { StringBuilder builder = new StringBuilder(); for (CharSequence s : arr) { builder.append(s); } return builder.toString(); } }