Date Pattern Tester & Translator · Tutorial

How to fix a date pattern showing minutes as the month

4 min readbeginnerUpdated

Your app prints 2026-07-04 for 4 March, and the middle number changes every time you refresh. The pattern uses mm (minutes) where it needs MM (month). You'll see the mistake in the tester, fix it, and check the result on an awkward date.

What you need

Steps

  1. Paste the pattern

    Choose Java (DateTimeFormatter) under Language and paste the pattern. For 4 March 2026 at 15:07 the result is 2026-07-04 15:07, with the minutes in the month's place.

    yyyy-mm-dd HH:mm
  2. Read the code table

    The table lists mm as Minute, 2 digits, not the month. The same letters mean the same in date-fns, Moment and .NET.

  3. Fix the pattern

    Change the first mm to MM. The result becomes 2026-03-04 15:07.

    yyyy-MM-dd HH:mm
  4. Test an edge case

    Set Date and time to 31 December at 23:59 and check that the year, month and day are still right. If you had used YYYY, the tester would warn that it is the week-based year.

Try it yourself

Opens the Date Pattern Tester & Translator with this tutorial's sample loaded.

Try it now

Common mistakes

Fixing only one mm
The pattern needs MM for the month and mm for minutes. Swapping both just moves the problem.
Mixing up DD and dd
In Java and date-fns, DD is the day of the year. Use dd for the day of the month.
Lower-case hh without AM/PM
hh is the 12-hour clock. Use HH for 24-hour time, or add a for AM/PM.

Next steps

Go back to the Date Pattern Tester & Translator, or keep going with one of these: