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
- The Date Pattern Tester
- The pattern from your Python code (the Try it button loads an example)
Steps
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:%SRead 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:%sand PostgreSQL usesDD/MM/YYYY HH24:MI:SS.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.
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.
Common mistakes
- Translating letter by letter
%M(minutes) is notMM(month) in Java. Always translate by meaning, which is what the table does.- Forgetting literal text
- Letters such as the
Tin 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
%-dworks 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: