public static String formatView(long views) { if (views < 1) { return "0"; } else if (views < TEN_THOUSAND) { return views + ""; } else if (views < ONE_HUNDRED_MILLION) { BigDecimal view = (BigDecimal.valueOf(views).divide(BigDecimal.valueOf(TEN_THOUSAND)) .setScale(1, RoundingMode.DOWN)); if (view.compareTo(BigDecimal.valueOf(view.intValue())) == 0) { return view.intValue() + "万"; } return view + "万"; } else { BigDecimal view = (BigDecimal.valueOf(views).divide(BigDecimal.valueOf(ONE_HUNDRED_MILLION)) .setScale(1, RoundingMode.DOWN)); if (view.compareTo(BigDecimal.valueOf(view.intValue())) == 0) { return view.intValue() + "亿"; } return view + "亿"; } }