Skip to main content

DateTimeFormatter Cheat Sheet: Patterns, the yyyy vs YYYY Bug, Locales and ISO Formats

A Java DateTimeFormatter cheat sheet where every output was run on JDK 25: pattern letters, why YYYY prints next year in late December (36 wrong days in 11 years for en_US and en_IN), the U+202F space that breaks AM/PM parsing since JDK 20, SMART vs STRICT parsing of 31 February, ISO constants, and a shared SimpleDateFormat that returns wrong dates.

equals() and hashCode() in Java: The Contract, Real Bugs and How Records Change It

Why Java needs both equals() and hashCode(), shown by breaking them: a HashSet holding duplicates, a constant hash costing 2,002,999 comparisons for 2,000 lookups, a mutated key that get() and remove() cannot find, record edge cases, and the JPA entity id trap. Every output is from a JDK 25 run and a committed transcript.

String.format, formatted() and printf in Java: The Complete Cheat Sheet

A Java String.format cheat sheet where every output was run on JDK 25: specifier anatomy, padding and alignment, why %.2f can disagree with C, locale traps, the lakh/crore grouping Formatter cannot produce (with a working formatter), the exceptions it throws, and what it costs against +.

MCP Beyond Tools in Java: Resources, Prompts, Sampling and Elicitation

Most MCP servers stop at tools. This post builds an incident-desk server in Java with resources, a prompt, sampling and elicitation on Spring AI 2.0.2 and MCP SDK 2.1.0, then breaks it on purpose: a client without the capability, a slow client, a stateless server that silently drops every tool, and what the 2026-07-28 spec changes.