Skip to content

Commit e2e5be5

Browse files
authored
Update datetime.md
1 parent 8db7baf commit e2e5be5

1 file changed

Lines changed: 8 additions & 1 deletion

File tree

datetime.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,6 +339,13 @@ DST End Day (25-hour day):
339339
**Q:** On DST end day, if you calculate hours between 4:00 AM and 2:00 AM, why might the result be -3 instead of -2?
340340
**A:** Because the 2:00 AM hour occurs twice on DST end day. Going from 4:00 AM to 2:00 AM crosses the repeated hour, requiring an extra hour: 4→3→2(first)→2(repeated) = 3 hours backward = -3.
341341

342+
| Method | DST-aware? | Use with | Notes |
343+
|-----------------------------|------------|---------------------------------|-------------------------------------------------------------|
344+
| Period.between() | ❌ No | LocalDate only | Measures difference in years, months, days; ignores time. |
345+
| Duration.between() | ✅ Yes | ZonedDateTime, Instant, LocalTime | Measures difference in hours, minutes, seconds; affected by DST transitions. |
346+
| ChronoUnit.between() | ✅ Yes | ZonedDateTime, Instant, LocalDate, LocalTime | Flexible unit-based difference; DST-aware when used with ZonedDateTime. |
347+
| ChronoUnit.DAYS.between() | ❌ No | LocalDate | Simple day difference ignoring time and DST. |
348+
342349
---
343350

344351
## 🃏 Localization - Locale and Resource Bundles
@@ -417,4 +424,4 @@ System.out.println(now.format(frenchFormat)); // 20/03/2024
417424
**💡 Learning Tip:** Think "LOCALE = WHERE, BUNDLE = WHAT" - Locale specifies location/language, ResourceBundle provides localized content with automatic fallback.
418425

419426
**Q:** If you request a ResourceBundle for Locale("de", "CH") but only have messages_de.properties and messages.properties, which file is used?
420-
**A:** messages_de.properties — the search falls back from de_CH to de to default, using the most specific match found.
427+
**A:** messages_de.properties — the search falls back from de_CH to de to default, using the most specific match found.

0 commit comments

Comments
 (0)