René's URL Explorer Experiment
Title: Date formatting | java.evolved
Open Graph Title: Date formatting | java.evolved
X Title: Date formatting | java.evolved
Description: Format dates with thread-safe, immutable DateTimeFormatter.
Open Graph Description: Format dates with thread-safe, immutable DateTimeFormatter.
X Description: Format dates with thread-safe, immutable DateTimeFormatter.
Opengraph URL: https://javaevolved.github.io/datetime/date-formatting.html
direct link
Domain: javaevolved.github.io
Hey, it has json ld scripts:
{
"@context": "https://schema.org",
"@type": "TechArticle",
"headline": "Date formatting",
"description": "Format dates with thread-safe, immutable DateTimeFormatter.",
"url": "https://javaevolved.github.io/date-formatting.html",
"publisher": {
"@type": "Organization",
"name": "java.evolved",
"url": "https://javaevolved.github.io"
},
"mainEntityOfPage": {
"@type": "WebPage",
"@id": "https://javaevolved.github.io/date-formatting.html"
}
}
{
"@context": "https://schema.org",
"@type": "BreadcrumbList",
"itemListElement": [
{
"@type": "ListItem",
"position": 1,
"name": "Home",
"item": "https://javaevolved.github.io/"
},
{
"@type": "ListItem",
"position": 2,
"name": "Date/Time",
"item": "https://javaevolved.github.io/#datetime"
},
{
"@type": "ListItem",
"position": 3,
"name": "Date formatting"
}
]
}
| theme-color | #f97316 |
| mobile-web-app-capable | yes |
| apple-mobile-web-app-status-bar-style | black-translucent |
| apple-mobile-web-app-title | java.evolved |
| og:type | article |
| og:site_name | java.evolved |
| og:locale | en |
| og:image | https://javaevolved.github.io/og/datetime/date-formatting.png |
| og:image:width | 1200 |
| og:image:height | 630 |
| og:image:type | image/png |
| twitter:card | summary_large_image |
| twitter:image | https://javaevolved.github.io/og/datetime/date-formatting.png |
Links:
| java.evolved | https://javaevolved.github.io/ |
|
| https://github.com/javaevolved/javaevolved.github.io |
| ← All patterns | https://javaevolved.github.io/ |
| ← | https://javaevolved.github.io/datetime/duration-and-period.html |
| → | https://javaevolved.github.io/datetime/instant-precision.html |
| Home | https://javaevolved.github.io/ |
| Date/Time | https://javaevolved.github.io/#datetime |
| 🐛 Report a code issue | https://github.com/javaevolved/javaevolved.github.io/issues/new?template=code-issue.yml&title=%5BCode%20Issue%5D%20Date%20formatting&category=datetime&slug=date-formatting |
| 🌐 Report a translation issue | https://github.com/javaevolved/javaevolved.github.io/issues/new?template=translation-issue.yml&title=%5BTranslation%5D%20Date%20formatting%20%28English%29&locale=en&pattern=date-formatting&area=Pattern%20content |
| 💡 Suggest a new pattern | https://github.com/javaevolved/javaevolved.github.io/issues/new?template=new-pattern.yml |
| 𝕏 | https://x.com/intent/tweet?url=https%3A%2F%2Fjavaevolved.github.io%2Fdatetime%2Fdate-formatting.html&text=Date%20formatting%20%E2%80%93%20java.evolved |
| 🦋 | https://bsky.app/intent/compose?text=Date%20formatting%20%E2%80%93%20java.evolved%20https%3A%2F%2Fjavaevolved.github.io%2Fdatetime%2Fdate-formatting.html |
| in | https://www.linkedin.com/sharing/share-offsite/?url=https%3A%2F%2Fjavaevolved.github.io%2Fdatetime%2Fdate-formatting.html |
| ⬡ | https://www.reddit.com/submit?url=https%3A%2F%2Fjavaevolved.github.io%2Fdatetime%2Fdate-formatting.html&title=Date%20formatting%20%E2%80%93%20java.evolved |
| Let us know. | https://github.com/javaevolved/javaevolved.github.io/issues/new?template=code-issue.yml&title=%5BCode%20Issue%5D%20Date%20formatting&category=datetime&slug=date-formatting |
| DateTimeFormatter ↗ | https://docs.oracle.com/en/java/javase/25/docs/api/java.base/java/time/format/DateTimeFormatter.html |
| View proof source ↗ | https://github.com/javaevolved/javaevolved.github.io/blob/main/proof/datetime/DateFormatting.java |
|
Date/Time
Intermediate
Instant with nanosecond precision
Java 8
// Millisecond precision only
long millis =
System.currentTimeMillis();
// 1708012345678
Java 9+
// Microsecond/nanosecond precision
Instant now = Instant.now();
// 2025-02-15T20:12:25.678901234Z
long nanos = now.getNano();
Hover to see modern ➜
JDK 9+
→
| https://javaevolved.github.io/datetime/instant-precision.html |
|
Date/Time
Beginner
java.time API basics
Pre-Java 8
// Mutable, confusing, zero-indexed months
Calendar cal = Calendar.getInstance();
cal.set(2025, 0, 15); // January = 0!
Date date = cal.getTime();
// not thread-safe
Java 8+
LocalDate date = LocalDate.of(
2025, Month.JANUARY, 15);
LocalTime time = LocalTime.of(14, 30);
Instant now = Instant.now();
// immutable, thread-safe
Hover to see modern ➜
JDK 8+
→
| https://javaevolved.github.io/datetime/java-time-basics.html |
|
Date/Time
Intermediate
HexFormat
Java 8
// Pad to 2 digits, uppercase
String hex = String.format(
"%02X", byteValue);
// Parse hex string
int val = Integer.parseInt(
"FF", 16);
Java 17+
var hex = HexFormat.of()
.withUpperCase();
String s = hex.toHexDigits(
byteValue);
byte[] bytes =
hex.parseHex("48656C6C6F");
Hover to see modern ➜
JDK 17+
→
| https://javaevolved.github.io/datetime/hex-format.html |
| java.evolved | https://javaevolved.github.io/ |
| Bruno Borges | https://github.com/brunoborges |
| GitHub Copilot | https://github.com/features/copilot |
| modern-css.com | https://modern-css.com |
| View on GitHub | https://github.com/javaevolved/javaevolved.github.io |
Viewport: width=device-width, initial-scale=1.0
Robots: index, follow
URLs of crawlers that visited me.