Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. /// 金额分 数字格式化 如 4132 --> 4,132.00
  2. func decimalFormatterValue(value: Int) -> String? {
  3. let decimal = value % 100
  4. let nonDecimal = value / 100
  5. let formatter = NumberFormatter.init()
  6. formatter.numberStyle = .decimal
  7. if let title = formatter.string(from: NSNumber.init(value: nonDecimal)) {
  8. return title + String.init(format: ".%02d", decimal)
  9. }
  10. return nil
  11. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement