From 163d8d3811142e7f2eb518ae66a1a6ec48b5479d Mon Sep 17 00:00:00 2001 From: Zihlu Wang Date: Tue, 30 Apr 2024 11:10:50 +0800 Subject: [PATCH] refactor: renamed DateAndTimeFormatter to Formatters BREAKING CHANGE: com.onixbyte.webcal.config.DateAndTimeFormatter is being moved to com.onixbyte.webcal.config.Formatters --- .../config/{DateAndTimeFormatter.java => Formatters.java} | 8 +++++++- .../java/com/onixbyte/webcal/impl/WebCalendarEvent.java | 6 +++--- 2 files changed, 10 insertions(+), 4 deletions(-) rename webcal/src/main/java/com/onixbyte/webcal/config/{DateAndTimeFormatter.java => Formatters.java} (90%) diff --git a/webcal/src/main/java/com/onixbyte/webcal/config/DateAndTimeFormatter.java b/webcal/src/main/java/com/onixbyte/webcal/config/Formatters.java similarity index 90% rename from webcal/src/main/java/com/onixbyte/webcal/config/DateAndTimeFormatter.java rename to webcal/src/main/java/com/onixbyte/webcal/config/Formatters.java index 57b0eb8..89c1d31 100644 --- a/webcal/src/main/java/com/onixbyte/webcal/config/DateAndTimeFormatter.java +++ b/webcal/src/main/java/com/onixbyte/webcal/config/Formatters.java @@ -26,7 +26,7 @@ import java.util.Objects; * * @author Zihlu Wang */ -public final class DateAndTimeFormatter { +public final class Formatters { /** * Get the {@link java.time.format.DateTimeFormatter datetime formatter} @@ -45,4 +45,10 @@ public final class DateAndTimeFormatter { private static DateTimeFormatter utcDateTimeFormatter; + /** + * Private constructor to prevent this class being initialised. + */ + private Formatters() { + } + } diff --git a/webcal/src/main/java/com/onixbyte/webcal/impl/WebCalendarEvent.java b/webcal/src/main/java/com/onixbyte/webcal/impl/WebCalendarEvent.java index 07b64f1..de26f5e 100644 --- a/webcal/src/main/java/com/onixbyte/webcal/impl/WebCalendarEvent.java +++ b/webcal/src/main/java/com/onixbyte/webcal/impl/WebCalendarEvent.java @@ -19,7 +19,7 @@ package com.onixbyte.webcal.impl; import com.onixbyte.webcal.WebCalendarNode; import com.onixbyte.webcal.config.Classification; -import com.onixbyte.webcal.config.DateAndTimeFormatter; +import com.onixbyte.webcal.config.Formatters; import java.text.MessageFormat; import java.time.Duration; @@ -269,8 +269,8 @@ public final class WebCalendarEvent extends WebCalendarNode { END:{0}""", /* 0 - tag */TAG, /* 1 - uid */ Optional.ofNullable(uid).orElse(UUID.randomUUID().toString()) + "@" + domainName, - /* 2 - dtstamp */ now.format(DateAndTimeFormatter.getUtcDatetimeFormatter()), - /* 3 - start time */ start.atZone(ZoneId.systemDefault()).format(DateAndTimeFormatter.getUtcDatetimeFormatter()), + /* 2 - dtstamp */ now.format(Formatters.getUtcDatetimeFormatter()), + /* 3 - start time */ start.atZone(ZoneId.systemDefault()).format(Formatters.getUtcDatetimeFormatter()), /* 4 - summary */ Optional.ofNullable(summary).map((item) -> "\nSUMMARY:" + item).orElse(""), /* 5 - categories */ Optional.ofNullable(categories) .map((item) -> !item.isEmpty() ? "\nCATEGORIES:" + resolveCategories() : null).orElse(""),