numberutil.java

来自「cwbbs 云网论坛源码」· Java 代码 · 共 48 行

JAVA
48
字号
package cn.js.fan.util;import java.text.DecimalFormat;public class NumberUtil {  public NumberUtil() {  }    public static String round(double v,int scale) {                String temp = "##0.";    for (int i = 0; i < scale; i++) {      temp += "0";    }    DecimalFormat d = new DecimalFormat(temp);    return d.format(v);  }    public static String roundRMB(double v) {    String temp = "##0.00";    DecimalFormat d = new DecimalFormat(temp);    return d.format(v);  }    public static String roundRMB2Feng(double v) {        String temp = "##0.";    DecimalFormat d = new DecimalFormat(temp);    d.setDecimalSeparatorAlwaysShown(false);    return d.format(v*100);  }    public static int random(int a, int b) {      return (int)((b-a)*Math.random() + a);  }  public static long random(long a, long b) {      return (long)((b-a)*Math.random() + a);  }}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?