# \#formatter

**URL:** https://forums.swift.org/tag/formatter/534.md

[Latest](https://forums.swift.org/latest.md) · [Categories](https://forums.swift.org/categories.md) · [Tags](https://forums.swift.org/tags.md)

---

## [I'm confused how to consistently format Swift code](https://forums.swift.org/t/im-confused-how-to-consistently-format-swift-code/81780)

<div class="topic-metadata">

**Author:** [@lukaszciastko](https://forums.swift.org/u/lukaszciastko)\
**Replies:** 5\
**Last updated:** [August 25, 2025, 12:01pm UTC](https://forums.swift.org/t/im-confused-how-to-consistently-format-swift-code/81780 "2025-08-25T12:01:47Z")

</div>

Hi, I’ve been trying to find a consistent way to format my code, but I’m confused how it all works… Is there a way to format code from command line in the same way Xcode (Format file with ‘swift-format’) or VS Code (Sh…

---

## [Rounding error in milliseconds using ISO8601FormatStyle instead of ISO8601DateFormatter](https://forums.swift.org/t/rounding-error-in-milliseconds-using-iso8601formatstyle-instead-of-iso8601dateformatter/75206)

<div class="topic-metadata">

**Author:** [@jvdvleuten](https://forums.swift.org/u/jvdvleuten)\
**Replies:** 4\
**Last updated:** [October 11, 2024, 6:18pm UTC](https://forums.swift.org/t/rounding-error-in-milliseconds-using-iso8601formatstyle-instead-of-iso8601dateformatter/75206 "2024-10-11T18:18:34Z")

</div>

Hey there, I was using the new ISO8601FormatStyle and using the includingFractionalSeconds option for it. But when decoding and encoding an iso8601 string, I do get rounding errors in the millisecond part. I have setup…

---

## [Date.ParseStrategy(dateString:) overload?](https://forums.swift.org/t/date-parsestrategy-datestring-overload/70649)

<div class="topic-metadata">

**Author:** [@carlynorama](https://forums.swift.org/u/carlynorama)\
**Replies:** 3\
**Last updated:** [March 28, 2024, 2:03pm UTC](https://forums.swift.org/t/date-parsestrategy-datestring-overload/70649 "2024-03-28T14:03:06Z")

</div>

So I like a lot about how the new Date formatting options work, but sometimes I find the "format" part super verbose as I already have a whole cheat sheet of the styles I use and a String is a lot easier to store and pas…

---

## [Question about round-tripping with Date.ParseStrategy and Date.FormatStyle](https://forums.swift.org/t/question-about-round-tripping-with-date-parsestrategy-and-date-formatstyle/70590)

<div class="topic-metadata">

**Author:** [@James\_Dempsey](https://forums.swift.org/u/James_Dempsey)\
**Replies:** 4\
**Last updated:** [March 12, 2024, 3:19am UTC](https://forums.swift.org/t/question-about-round-tripping-with-date-parsestrategy-and-date-formatstyle/70590 "2024-03-12T03:19:28Z")

</div>

I am working with a text file format that I do not have control over. Dates are represented with strings like "2014\_03\_11" using an underscore to separate them rather than a space or a hyphen. I am able to create a Dat…

---

## [How to parse dates formatted like "2020-09-16 23:44:47 +0200" for use in RegexBuilders](https://forums.swift.org/t/how-to-parse-dates-formatted-like-2020-09-16-2347-0200-for-use-in-regexbuilders/58243)

<div class="topic-metadata">

**Author:** [@dirk68](https://forums.swift.org/u/dirk68)\
**Replies:** 6\
**Last updated:** [June 20, 2022, 10:27am UTC](https://forums.swift.org/t/how-to-parse-dates-formatted-like-2020-09-16-2347-0200-for-use-in-regexbuilders/58243 "2022-06-20T10:27:18Z")

</div>

I, tried to parse a date in the following format and failed miserably: 2020-09-16 23:44:47 +0200 I wanted to parse a file containing dates in this format using the new RegexBuilders. I was not able to generate or pars…

---

## [How to update \`TextField\` text with custom formatter prefix](https://forums.swift.org/t/how-to-update-textfield-text-with-custom-formatter-prefix/55073)

<div class="topic-metadata">

**Author:** [@Damu](https://forums.swift.org/u/Damu)\
**Replies:** 0\
**Last updated:** [February 3, 2022, 12:58pm UTC](https://forums.swift.org/t/how-to-update-textfield-text-with-custom-formatter-prefix/55073 "2022-02-03T12:58:22Z")

</div>

I would like to create a custom Formatter to TextField. Here I have done some workaround but it's not working as expected. We should show text in the formate of USD$ 200.00 USD$ prefix should show in the text field. s…

---

## [How to create custom \`IntegerFormatStyle\` formatter in Foundation?](https://forums.swift.org/t/how-to-create-custom-integerformatstyle-formatter-in-foundation/49644)

<div class="topic-metadata">

**Author:** [@BasemEmara](https://forums.swift.org/u/BasemEmara)\
**Replies:** 7\
**Last updated:** [July 16, 2021, 6:15pm UTC](https://forums.swift.org/t/how-to-create-custom-integerformatstyle-formatter-in-foundation/49644 "2021-07-16T18:15:08Z")

</div>

Is it possible to create custom styles with the new Foundation formatters that were introduced in WWDC 2021? Currently, you could format numbers like this: print(40.formatted(.percent)) // 40% print(40.formatted(.c…
