com.suyeer.basic.util.FormatUtil Maven / Gradle / Ivy
package com.suyeer.basic.util;
/**
* @author jun 2018/10/19
*/
public class FormatUtil {
public static Double fDouble(Double num, int precision) {
String formatStr = "%." + precision + "f";
String tmpStr = String.format(formatStr, num);
return Double.valueOf(tmpStr);
}
public static Float fFloat(Float num, int precision) {
String formatStr = "%." + precision + "f";
String tmpStr = String.format(formatStr, num);
return Float.valueOf(tmpStr);
}
}