UI: show timezone if different than local.

Fixes #1296.
This commit is contained in:
Dennis Guse
2022-08-22 18:23:24 +02:00
parent 27727b6dcf
commit 73e59cbba2
5 changed files with 16 additions and 12 deletions
@@ -61,13 +61,6 @@ public class StringUtils {
private StringUtils() {
}
/**
* Formats the date and time of the OffsetDateTime (using default Locale format)
*/
public static String formatDateTime(OffsetDateTime odt) {
return odt.format(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM));
}
/**
* Formats the date and time with the offset (using default Locale format).
*/
@@ -75,6 +68,13 @@ public class StringUtils {
return odt.toZonedDateTime().format(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL));
}
public static String formatDateTimeWithOffsetIfDifferent(OffsetDateTime odt) {
if (!odt.getOffset().equals(OffsetDateTime.now().getOffset())) {
return odt.toZonedDateTime().format(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL));
}
return odt.toZonedDateTime().format(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM));
}
public static String formatLocalDateTime(LocalDateTime localDateTime) {
return localDateTime.format(DateTimeFormatter.ofLocalizedDate(FormatStyle.FULL));
}