|
|
@@ -1,13 +1,16 @@
|
|
|
package net.ranides.assira.time2;
|
|
|
|
|
|
import lombok.experimental.UtilityClass;
|
|
|
+import net.ranides.assira.text.StringUtils;
|
|
|
import org.jetbrains.annotations.Contract;
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
import org.jetbrains.annotations.Nullable;
|
|
|
|
|
|
import java.time.ZonedDateTime;
|
|
|
import java.time.format.DateTimeFormatter;
|
|
|
+import java.time.format.TextStyle;
|
|
|
import java.util.Locale;
|
|
|
+import java.util.Objects;
|
|
|
|
|
|
@UtilityClass
|
|
|
public class DateTimeFormatters {
|
|
|
@@ -49,6 +52,15 @@ public class DateTimeFormatters {
|
|
|
return formatDate(DateTimeUtils.withZoneUtc(input));
|
|
|
}
|
|
|
|
|
|
+ @ZoneExplicit
|
|
|
+ @Contract("!null -> !null; null -> null")
|
|
|
+ public static @Nullable String formatPolishDate(@Nullable ZonedDate input) {
|
|
|
+ if(Objects.isNull(input)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return formatPolishDate(input.withMin());
|
|
|
+ }
|
|
|
+
|
|
|
@ZoneExplicit
|
|
|
@Contract("!null -> !null; null -> null")
|
|
|
public static @Nullable String formatPolishDate(@Nullable ZonedDateTime input) {
|
|
|
@@ -65,6 +77,12 @@ public class DateTimeFormatters {
|
|
|
return format(DATETIME, input);
|
|
|
}
|
|
|
|
|
|
+ // @todo rename to formatPolishDateHoursMinutes?
|
|
|
+ @Contract("!null -> !null; null -> null")
|
|
|
+ public static @Nullable String formatPolishDateTime(@Nullable ZonedDateTime input) {
|
|
|
+ return format(DATETIME, DateTimeUtils.withZonePolish(input));
|
|
|
+ }
|
|
|
+
|
|
|
@Contract("!null -> !null; null -> null")
|
|
|
public static @Nullable String formatDateTimePrecise(@Nullable ZonedDateTime input) {
|
|
|
return format(DATETIME_PRECISE, input);
|
|
|
@@ -97,6 +115,12 @@ public class DateTimeFormatters {
|
|
|
return format(YEAR, input);
|
|
|
}
|
|
|
|
|
|
+ @ZoneExplicit
|
|
|
+ @Contract("!null -> !null; null -> null")
|
|
|
+ public static @Nullable String formatPolishYear(@Nullable ZonedDateTime input) {
|
|
|
+ return format(YEAR, DateTimeUtils.withZonePolish(input));
|
|
|
+ }
|
|
|
+
|
|
|
@Contract("!null -> !null; null -> null")
|
|
|
public static @Nullable String formatDateShort(@Nullable ZonedDateTime input) {
|
|
|
return format(DATENAME, input);
|
|
|
@@ -119,12 +143,29 @@ public class DateTimeFormatters {
|
|
|
return format(DAY_NAME, input);
|
|
|
}
|
|
|
|
|
|
+
|
|
|
+
|
|
|
@ZoneExplicit
|
|
|
@Contract("!null -> !null; null -> null")
|
|
|
public static @Nullable String getPolishDayName(@Nullable ZonedDateTime input) {
|
|
|
return format(DAY_NAME, LOCALE_PL, input);
|
|
|
}
|
|
|
|
|
|
+ @ZoneExplicit
|
|
|
+ @Contract("_,!null -> !null; _,null -> null")
|
|
|
+ public static @Nullable String getPolishMonthName(@NotNull Locale locale, @Nullable ZonedDateTime input) {
|
|
|
+ if(Objects.isNull(input)) {
|
|
|
+ return null;
|
|
|
+ }
|
|
|
+ return StringUtils.capitalize(input.getMonth().getDisplayName(TextStyle.FULL_STANDALONE, locale));
|
|
|
+ }
|
|
|
+
|
|
|
+ @ZoneExplicit
|
|
|
+ @Contract("!null -> !null; null -> null")
|
|
|
+ public static @Nullable String getPolishMonthName(@Nullable ZonedDateTime input) {
|
|
|
+ return getPolishMonthName(LOCALE_PL, input);
|
|
|
+ }
|
|
|
+
|
|
|
@ZoneExplicit
|
|
|
@Contract("!null -> !null; null -> null")
|
|
|
public static @Nullable String getPolishTime(@Nullable ZonedDateTime input) {
|