Class OpenNumberFormat
java.lang.Object
cloud.opencode.base.string.format.OpenNumberFormat
Number Format Utility - Provides number formatting methods.
数字格式化工具 - 提供数字格式化方法。
Features | 主要功能:
- Decimal number formatting with grouping - 分组小数格式化
- Percentage formatting - 百分比格式化
- Currency formatting - 货币格式化
- Chinese number conversion - 中文数字转换
- Chinese money conversion - 中文金额转换
Usage Examples | 使用示例:
String num = OpenNumberFormat.formatNumber(1234.5, 2); // "1,234.50"
String pct = OpenNumberFormat.formatPercent(0.85); // "85.00%"
String cn = OpenNumberFormat.toChineseNumber(123); // "壹佰贰拾叁"
Security | 安全性:
- Thread-safe: Yes (stateless utility, new DecimalFormat per call) - 线程安全: 是(无状态,每次调用创建新DecimalFormat)
- Null-safe: Yes - 空值安全: 是
- Since:
- JDK 25, opencode-base-string V1.0.0
- Author:
- Leon Soo www.LeonSoo.com
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionstatic StringformatCurrency(BigDecimal amount) static StringformatCurrency(BigDecimal amount, String symbol) static StringformatNumber(Number number) static StringformatNumber(Number number, int scale) static StringformatPercent(double number) static StringformatPercent(double number, int scale) static StringtoChineseMoney(BigDecimal amount) static StringtoChineseNumber(long number)
-
Method Details
-
formatNumber
-
formatNumber
-
formatPercent
-
formatPercent
-
formatCurrency
-
formatCurrency
-
toChineseNumber
-
toChineseMoney
-