Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /// 金额分 数字格式化 如 4132 --> 4,132.00
- func decimalFormatterValue(value: Int) -> String? {
- let decimal = value % 100
- let nonDecimal = value / 100
- let formatter = NumberFormatter.init()
- formatter.numberStyle = .decimal
- if let title = formatter.string(from: NSNumber.init(value: nonDecimal)) {
- return title + String.init(format: ".%02d", decimal)
- }
- return nil
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement