java 获取指定范围随机数
public Double nextDouble(double min, double max) throws Exception {
if (max < min) {
throw new BusinessException(CodeMsg.create(40001,"min > max"));
}
if (min == max) {
return min;
}
Double v = min + ((max - min) * new Random().nextDouble());
String format = String.format("%.5f", v);
return Double.parseDouble(format);
}