Here you can find the source of formatNumberFloorWithPostfix(int value)
Parameter | Description |
---|---|
value | a parameter |
public static String formatNumberFloorWithPostfix(int value)
//package com.java2s; //License from project: LGPL public class Main { /**//from w w w. ja v a 2s. c o m * Formats the number in value into a floored, postfixed form for display. * Supported formats are: 0..1000, 1.0k..9.9k, 10k..999k, 1M..nM * @param value * @return */ public static String formatNumberFloorWithPostfix(int value) { if (value >= 1000000000) { return String.format("%dG", value / 1000000000); } if (value >= 1000000) { return String.format("%dM", value / 1000000); } if (value >= 10000) { return String.format("%dk", value / 1000); } if (value > 1000) { return String.format("%.1fk", ((float) value) / 1000); } return String.valueOf(value); } }