/**
* 数字处理类
* @Author : wangchi
* @Date 2021/1/14 9:57
*/
public class NumberUtils {
private static final Integer TEN_THOUSAND = 10000;
private static final Integer THOUSAND = 1000;
private static final Integer HUNDRED = 100;
private static final String TEN_THOUSAND_STRING = "万";
private static final String POINT_STRING = ".";
/**
* 将整数超过万的转换成,有两位精度的描述
* 比如 : 123000 -> 12.30万
* @return
*/
public static String convertIntegerToTenThousand(Integer inputNumber){
if(ObjectUtils.isEmpty(inputNumber)){
return "";
}
StringBuffer convertNumber = new StringBuffer();
if (inputNumber > TEN_THOUSAND){
Integer tenThousand = inputNumber/TEN_THOUSAND;
Integer thousand = (inputNumber/THOUSAND)%tenThousand;
Integer hundred = (inputNumber/HUNDRED)%(inputNumber/THOUSAND);
convertNumber.append(tenThousand).append(POINT_STRING).append(thousand).append(hundred);
convertNumber.append(TEN_THOUSAND_STRING);
}else{
convertNumber.append(inputNumber);
}
return convertNumber.toString();
}
public static void main(String[] args) {
Integer nun = 20480;
String s = convertIntegerToTenThousand(nun);
System.out.println(s);
}
}