Created
February 14, 2022 18:19
-
-
Save aboedo/cc1fff7275e2eaee476c6728e1a31674 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Foundation | |
let usLocale = Locale(identifier: "en-US") | |
let formatter = NumberFormatter() | |
formatter.numberStyle = .currency | |
formatter.locale = usLocale | |
formatter.currencyCode = "eur" | |
let formattedEurosInUS = formatter.string(from: NSNumber(value: 584.5))! | |
formatter.currencyCode = "usd" | |
let formattedDollarsInUS = formatter.string(from: NSNumber(value: 584.5))! | |
print(formattedEurosInUS) | |
print(formattedDollarsInUS) | |
let spainLocale = Locale(identifier: "es-ES") | |
formatter.locale = spainLocale | |
formatter.currencyCode = "eur" | |
let formattedEurosInSpain = formatter.string(from: NSNumber(value: 584.5))! | |
formatter.currencyCode = "usd" | |
let formattedDollarsInSpain = formatter.string(from: NSNumber(value: 584.5))! | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment