feat:完成小时榜功能
This commit is contained in:
@@ -110,11 +110,11 @@ public class FormatUtils {
|
||||
|
||||
//PK值相关格式化方式,统一方法,方便以后更改样式
|
||||
public static String formatPKValue(long value) {
|
||||
// if (value >= 1000000) return (value / 100) / 100f + "万";
|
||||
// if (value >= 1000000) return (value / 100) / 100f + "万";
|
||||
return String.valueOf(value);
|
||||
}
|
||||
|
||||
public static String formatRankValue(int goldAmount){
|
||||
|
||||
public static String formatRankValue(int goldAmount) {
|
||||
String strGoldAmount;
|
||||
if (goldAmount >= 10000) {
|
||||
BigDecimal b = BigDecimal.valueOf(goldAmount / 10000.0);
|
||||
@@ -126,4 +126,29 @@ public class FormatUtils {
|
||||
return strGoldAmount;
|
||||
}
|
||||
|
||||
/**
|
||||
* 超过单位值后,返回转换后的数值,否则返回原数值
|
||||
*
|
||||
* @param value
|
||||
* @param unitValue 单位值
|
||||
* @param unitName 单位名称/后缀
|
||||
* @return
|
||||
*/
|
||||
public static String formatUnit(long value, int unitValue, String unitName) {
|
||||
try {
|
||||
if (value >= unitValue) {
|
||||
BigDecimal b = BigDecimal.valueOf(value * 1.0 / unitValue);
|
||||
double df = b.setScale(1, BigDecimal.ROUND_HALF_UP).doubleValue();
|
||||
if (unitName != null) {
|
||||
return df + unitName;
|
||||
} else {
|
||||
return String.valueOf(df);
|
||||
}
|
||||
} else {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
return String.valueOf(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user