Here you can find the source of longToString(long value)
Parameter | Description |
---|---|
value | long number. |
public static String longToString(long value)
//package com.java2s; //License from project: Open Source License public class Main { /**//from w w w. j a v a2 s. c o m * Convert a Long number to a readable string. * * @param value long number. * @return the "human-friendly" (readable) number as a String. */ public static String longToString(long value) { return value >= 1e11 ? String.format("%.0fG", value / 1e9) : value >= 1e7 ? String.format("%.0fM", value / 1e6) : (value >= 1e4) ? String.format("%.0fK", value / 1e3) : Long.toString(value); } }