From 5fffdb55b79907b7c05adf07b6bb1e9772f85582 Mon Sep 17 00:00:00 2001 From: David Whitlock Date: Mon, 9 Jun 2025 20:59:42 -0700 Subject: [PATCH] Address #55 by hard-coding a specific time zone for the LocalDateTime instance and by warning about the non-breaking space in the formatted date/time. --- koans/app/config/PathToEnlightenment.xml | 52 ++++++++++++------------ koans/src/intermediate/AboutDates.java | 3 +- 2 files changed, 28 insertions(+), 27 deletions(-) diff --git a/koans/app/config/PathToEnlightenment.xml b/koans/app/config/PathToEnlightenment.xml index dd104446..6b4002f3 100755 --- a/koans/app/config/PathToEnlightenment.xml +++ b/koans/app/config/PathToEnlightenment.xml @@ -1,32 +1,32 @@ - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + - - - + + + diff --git a/koans/src/intermediate/AboutDates.java b/koans/src/intermediate/AboutDates.java index 4f324dee..abafd1c3 100644 --- a/koans/src/intermediate/AboutDates.java +++ b/koans/src/intermediate/AboutDates.java @@ -15,7 +15,7 @@ public class AboutDates { - private LocalDateTime date = LocalDateTime.ofInstant(Instant.ofEpochMilli(100010001000L), ZoneId.systemDefault()); + private LocalDateTime date = LocalDateTime.ofInstant(Instant.ofEpochMilli(100010001000L), ZoneId.of("-07:00")); @Koan public void dateToString() { @@ -42,6 +42,7 @@ public void usingDateTimeFormatterToFormatDate() { @Koan public void usingDateTimeFormatterToFormatDateShort() { + // Careful, formatted dates may contain non-breaking spaces! String formattedDate = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT).format(date); assertEquals(formattedDate, __); }