# Formatting

The money class provides a simple way of formatting currency using a pattern.

When you create a Currency instance you can provide a default format pattern which is used to format a Money instance when you call `Money.toString()`.

The CommonCurrencies have default formatters for each Currency which is consistent with that currencies standards.

In some cases you may however want to format a Money instances in a specific manner. In this case you can use:

`Money.format(String pattern)`

```dart
import 'package:money2/money2.dart';
     test('formatting', () {
        final usd = Currency.create('USD', 2);
        final one = Money.fromIntWithCurrency(100, usd);
        expect(one.format('S0'), equals(r'$1'));
      });
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://money2.onepub.dev/formatting.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
