Skip to content

The issue with NumberFormatter() and Locale.current  #565

Open
@sameers1995

Description

@sameers1995

Description
This bug is related to nil object returned when formatting using number formatter. When we changed the device location to spain it returned all nil values and for other locations it returns the exact expected formatted number.

Steps to reproduce
To reproduce it you have to use the following code snippet
let formatter = NumberFormatter()
formatter.locale = Locale.current
formatter.numberStyle = .decimal
let number = formatter.number(from: amount)

Once you build the app change the device location and you will see that this function returns nil value. For example number = nil

Expected behavior
Once the code snippet is executed it should set number as formatted amount based on the formatter applied.

Environment

  • Swift compiler version info swift-driver version: 1.75.2 Apple Swift version 5.8 (swiftlang-5.8.0.124.2 clang-1403.0.22.11.100)
    Target: arm64-apple-macosx13.0
  • Xcode version info 14.3 (14E222b)
  • Deployment target: 11.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions