Date Pattern Tester & Translator · Tutorial

How to translate a strftime pattern to Java and SQL

5 min readintermediateUpdated

A Python service writes log dates with strftime, and the Java and SQL code that reads them needs the same format. You'll paste the Python pattern once and copy the equivalent for every other language, checking for codes that don't translate.

What you need

Steps

  1. Enter the Python pattern

    Choose Python (strftime) and paste the pattern. The result shows the current time in that format, for example 04/03/2026 15:07:09.

    %d/%m/%Y %H:%M:%S
  2. Read the translations

    The lower table shows the same pattern in each language. Java and date-fns use dd/MM/yyyy HH:mm:ss, MySQL uses %d/%m/%Y %H:%i:%s and PostgreSQL uses DD/MM/YYYY HH24:MI:SS.

  3. Check notes and gaps

    Notes under a pattern point out codes that work differently or don't exist there, such as milliseconds in Python or the time zone name in MySQL.

  4. Copy and paste

    Press Copy next to the language you need. The usage line in the cheat sheet shows where the pattern goes in code.

Try it yourself

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

Try it now

Common mistakes

Translating letter by letter
%M (minutes) is not MM (month) in Java. Always translate by meaning, which is what the table does.
Forgetting literal text
Letters such as the T in ISO dates must be quoted in Java ('T'), Moment ([T]) and PHP (\T). The translation adds the quotes for you.
Platform-only codes
Python's %-d works on Linux and macOS but not Windows. The tester flags these codes.

Next steps

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