mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-07-21 15:09:48 +08:00
修复多线程下Sftp中Channel关闭的问题
This commit is contained in:
@@ -638,6 +638,20 @@ public class NumberUtil extends NumberValidator {
|
||||
format.setMaximumFractionDigits(scale);
|
||||
return format.format(number);
|
||||
}
|
||||
|
||||
/**
|
||||
* 格式化千分位表示方式,小数采用四舍五入方式
|
||||
*
|
||||
* @param number 值
|
||||
* @param scale 保留小数位数
|
||||
* @return 千分位数字
|
||||
* @since 6.0.0
|
||||
*/
|
||||
public static String formatThousands(final double number, final int scale) {
|
||||
final NumberFormat format = NumberFormat.getNumberInstance();
|
||||
format.setMaximumFractionDigits(scale);
|
||||
return format.format(number);
|
||||
}
|
||||
// endregion
|
||||
|
||||
// region ----- range
|
||||
|
@@ -746,4 +746,12 @@ public class NumberUtilTest {
|
||||
void issueI6ZD1RTest() {
|
||||
Assertions.assertFalse(NumberUtil.isInteger("999999999999999"));
|
||||
}
|
||||
|
||||
@Test
|
||||
void formatThousands() {
|
||||
// issue#I7OIA6
|
||||
Assertions.assertEquals(
|
||||
"123,456,789.111111",
|
||||
NumberUtil.formatThousands(123456789.111111D, 6));
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user