refactor: renamed DateAndTimeFormatter to Formatters

BREAKING CHANGE: com.onixbyte.webcal.config.DateAndTimeFormatter is being moved to
com.onixbyte.webcal.config.Formatters
This commit is contained in:
Zihlu Wang
2024-04-30 11:10:50 +08:00
parent 9c63a33643
commit 163d8d3811
2 changed files with 10 additions and 4 deletions
@@ -26,7 +26,7 @@ import java.util.Objects;
* *
* @author Zihlu Wang * @author Zihlu Wang
*/ */
public final class DateAndTimeFormatter { public final class Formatters {
/** /**
* Get the {@link java.time.format.DateTimeFormatter datetime formatter} * Get the {@link java.time.format.DateTimeFormatter datetime formatter}
@@ -45,4 +45,10 @@ public final class DateAndTimeFormatter {
private static DateTimeFormatter utcDateTimeFormatter; private static DateTimeFormatter utcDateTimeFormatter;
/**
* Private constructor to prevent this class being initialised.
*/
private Formatters() {
}
} }
@@ -19,7 +19,7 @@ package com.onixbyte.webcal.impl;
import com.onixbyte.webcal.WebCalendarNode; import com.onixbyte.webcal.WebCalendarNode;
import com.onixbyte.webcal.config.Classification; import com.onixbyte.webcal.config.Classification;
import com.onixbyte.webcal.config.DateAndTimeFormatter; import com.onixbyte.webcal.config.Formatters;
import java.text.MessageFormat; import java.text.MessageFormat;
import java.time.Duration; import java.time.Duration;
@@ -269,8 +269,8 @@ public final class WebCalendarEvent extends WebCalendarNode {
END:{0}""", END:{0}""",
/* 0 - tag */TAG, /* 0 - tag */TAG,
/* 1 - uid */ Optional.ofNullable(uid).orElse(UUID.randomUUID().toString()) + "@" + domainName, /* 1 - uid */ Optional.ofNullable(uid).orElse(UUID.randomUUID().toString()) + "@" + domainName,
/* 2 - dtstamp */ now.format(DateAndTimeFormatter.getUtcDatetimeFormatter()), /* 2 - dtstamp */ now.format(Formatters.getUtcDatetimeFormatter()),
/* 3 - start time */ start.atZone(ZoneId.systemDefault()).format(DateAndTimeFormatter.getUtcDatetimeFormatter()), /* 3 - start time */ start.atZone(ZoneId.systemDefault()).format(Formatters.getUtcDatetimeFormatter()),
/* 4 - summary */ Optional.ofNullable(summary).map((item) -> "\nSUMMARY:" + item).orElse(""), /* 4 - summary */ Optional.ofNullable(summary).map((item) -> "\nSUMMARY:" + item).orElse(""),
/* 5 - categories */ Optional.ofNullable(categories) /* 5 - categories */ Optional.ofNullable(categories)
.map((item) -> !item.isEmpty() ? "\nCATEGORIES:" + resolveCategories() : null).orElse(""), .map((item) -> !item.isEmpty() ? "\nCATEGORIES:" + resolveCategories() : null).orElse(""),