All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.suyeer.basic.util.FormatUtil Maven / Gradle / Ivy

There is a newer version: 6.0.1
Show newest version
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);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy