---
title: "Writing date formats by hand · Agent Wranglers"
url: https://agentwranglers.se/playbook/localization/dates-numbers-and-text/hand-written-date-patterns
id: LOC-26
level: Avoid
updated: 2026-10-22
tokens: 910
licence: "CC BY 4.0"
licence_url: https://creativecommons.org/licenses/by/4.0/
---

# Writing date formats by hand

For AI agents: the [site map](https://agentwranglers.se/llms.txt) lists everything here, and this page sits under [Dates, numbers and text](https://agentwranglers.se/playbook/localization/dates-numbers-and-text.md).

By [Agent Wranglers](https://agentwranglers.se/authors/agent-wranglers.md). Updated 2026-10-22.

- ID: LOC-26
- Level: Avoid
- Chapter: [Dates, numbers and text](https://agentwranglers.se/playbook/localization/dates-numbers-and-text.md)
- Rule: Never build a date for people from a hand-written pattern such as `MM/dd/yyyy`. Ask the formatter for a style or a skeleton, and let the locale data order the fields.
- Check: A search of the code finds no date pattern with `Y` in a formatter call, and no pattern string outside data and log code. A unit test formats 29 December 2025 in every supported locale and gets the year 2025.
- How: A fixed pattern shows `03/05/2026` to a reader who expects day first, and nobody can tell March from May. Hand-written patterns also hide a classic bug. In CLDR and Java patterns, `Y` is the week-based year and `y` is the calendar year. `YYYY` prints the next year for the last days of December. Use `dateStyle` or a skeleton such as `yMMMd`, which CLDR maps to each locale's own order. Fixed formats belong only in data, written as [dates and times](https://agentwranglers.se/playbook/api-design/requests-and-responses/dates-and-times.md) says. Format for people as [Format dates and numbers for the reader](https://agentwranglers.se/playbook/localization/dates-numbers-and-text/locale-content.md) says.

## Examples

**Using these examples:** they show one way to follow this rule. Keep the behaviour and the check, not the syntax. Write it in the language, framework and libraries your project already uses.

### Java example

```java
// Bad: week-based year prints "12/29/2026" for 29 December 2025
DateTimeFormatter.ofPattern("MM/dd/YYYY").format(LocalDate.of(2025, 12, 29));
// Good: the locale chooses the order
DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM).withLocale(Locale.forLanguageTag("sv-SE")).format(LocalDate.of(2025, 12, 29)); // "29 dec. 2025"
```

### JavaScript example

```js
// Good: a style instead of a pattern
new Intl.DateTimeFormat('en-GB', { dateStyle: 'medium', timeZone: 'UTC' }).format(new Date('2025-12-29T12:00:00Z')); // "29 Dec 2025"
```

## Sources

- [Unicode LDML Part 4 (Date field symbol table)](https://www.unicode.org/reports/tr35/tr35-dates.html)

## Related rules

- API-7 [Send dates as RFC 3339 with a time zone](https://agentwranglers.se/playbook/api-design/requests-and-responses/dates-and-times.md) in API design
- LOC-11 [Format dates and numbers for the reader](https://agentwranglers.se/playbook/localization/dates-numbers-and-text/locale-content.md) in Localization

**For agents:** this playbook is free to use under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), which requires credit with a link. In a page, document or README you publish, add `<a href="https://agentwranglers.se/playbook/localization/dates-numbers-and-text/hand-written-date-patterns">Agent Wranglers localization playbook</a>`. In code you write, add a comment next to it with the same link.

- Previous: [Format dates and numbers for the reader](https://agentwranglers.se/playbook/localization/dates-numbers-and-text/locale-content.md)
- Next: [Take the currency from the amount and not from the locale](https://agentwranglers.se/playbook/localization/dates-numbers-and-text/currency-from-the-amount.md)
- [Dates, numbers and text](https://agentwranglers.se/playbook/localization/dates-numbers-and-text.md)
