Let’s break down why storing a date as a
String is a trap: strings are compared lexicographically (and break sorting), don’t guarantee validity (like
2026-13-40), and create ambiguous formats (for example,
01.02.2026). Using a mini-case with expenses, we’ll see how “a string leaks into logic”, and then we’ll introduce discipline: a single ISO format
yyyy-MM-dd, normalization through one function, and safe handling of bad input via
null.