money2
Search…
Overview
Common Currencies
Creating a Currency
Registering a Currency
Parsing
Find a currency
Default format
Symbols
Separators
Creating Money
Money.parse
Currency.parse
Money.from
Currencies.parse
Scale
Formatting
Storing and Send
Exchange Rates
Comparison
Currency Predicates
Value Sign Predicates
Arithmetic Operations
Allocation
Money encoding/decoding
Powered By
GitBook
Currency.parse
The simplest variant of
Currency.parse
relies on the default pattern of the currency.
1
test
(
'parse with Currency'
,
()
{
2
/// Parse using a currency.
3
var
t1
=
CommonCurrencies
().
aud
.
parse
(
r'
$
10
.00'
);
4
expect
(
t1
.
toString
(),
equals
(
r'
$
10
.00'
));
5
expect
(
t1
.
currency
.
code
,
equals
(
'AUD'
));
6
});
Copied!
You can also pass an explict pattern.
1
var
t2
=
CommonCurrencies
().
aud
.
parse
(
r'10.00#x27;
,
pattern
:
'0.00S'
);
2
expect
(
t2
.
toString
(),
equals
(
r'
$
10
.00'
));
3
expect
(
t2
.
currency
.
code
,
equals
(
'AUD'
));
Copied!
Previous
Money.parse
Next
Money.from
Last modified
7mo ago
Copy link