Skip to content

Commit 2cce366

Browse files
committed
Fixed: Failed to format LocalDate, as formatter expected time
1 parent fd31561 commit 2cce366

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

β€Žsrc/main/java/CindyBootstrap.javaβ€Ž

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@
6666
public final class CindyBootstrap {
6767
private static final int MAXIMUM_MASTODON_MESSAGE_LENGTH = 500;
6868
private static final DateTimeFormatter GERMAN_TIMESTAMP_FORMATTER = DateTimeFormatter.ofPattern("d. LLLL yyyy HH:mm", GERMANY);
69+
private static final DateTimeFormatter GERMAN_DATE_FORMATTER = DateTimeFormatter.ofPattern("d. LLLL yyyy", GERMANY);
6970
private static final Logger LOGGER = Logger.getLogger(CindyBootstrap.class.getName());
7071
private static final ZoneId EUROPE_BERLIN = ZoneId.of("Europe/Berlin");
7172

@@ -218,8 +219,15 @@ public void run() {
218219
message.setLength(0);
219220
if (event.summary() != null)
220221
message.append("πŸ“’ ").append(event.summary());
221-
if (event.begin() != null)
222-
message.append("\nπŸ“… ").append(GERMAN_TIMESTAMP_FORMATTER.format(event.begin()));
222+
switch (event.begin()) {
223+
case null:
224+
break;
225+
case LocalDate ld:
226+
message.append("\nπŸ“… ").append(GERMAN_DATE_FORMATTER.format(ld));
227+
break;
228+
default:
229+
message.append("\nπŸ“… ").append(GERMAN_TIMESTAMP_FORMATTER.format(event.begin()));
230+
}
223231
if (event.location() != null)
224232
message.append("\n🏠️ ").append(event.location());
225233
final var splr = message.toString();

0 commit comments

Comments
Β (0)