summaryrefslogtreecommitdiff
path: root/src/main/java
diff options
context:
space:
mode:
authorMatthias Andreas Benkard <code@mail.matthias.benkard.de>2020-04-26 13:14:21 +0200
committerMatthias Andreas Benkard <code@mail.matthias.benkard.de>2020-04-26 18:38:45 +0200
commit369e698b0761a0c0abb460e92d680ae441374422 (patch)
treee1fb9358f85fe07bf28fcea8923dafb573d6aca3 /src/main/java
parentb3ff7ac842c385bb7c1a99d794a0c57830f58ea7 (diff)
KB54 Group posts by date, use floating to make style sheet even more compact.
Change-Id: I41346eb51481d4c2c4e7066373fba5b7073e3e4f
Diffstat (limited to 'src/main/java')
-rw-r--r--src/main/java/eu/mulk/mulkcms2/benki/posts/PostResource.java31
1 files changed, 28 insertions, 3 deletions
diff --git a/src/main/java/eu/mulk/mulkcms2/benki/posts/PostResource.java b/src/main/java/eu/mulk/mulkcms2/benki/posts/PostResource.java
index 92e2f4e..1fa7a26 100644
--- a/src/main/java/eu/mulk/mulkcms2/benki/posts/PostResource.java
+++ b/src/main/java/eu/mulk/mulkcms2/benki/posts/PostResource.java
@@ -61,11 +61,18 @@ public abstract class PostResource {
private static final Logger log = Logger.getLogger(PostResource.class);
- private static final DateTimeFormatter htmlDateFormatter = DateTimeFormatter.ISO_OFFSET_DATE_TIME;
+ private static final DateTimeFormatter htmlDateTimeFormatter =
+ DateTimeFormatter.ISO_OFFSET_DATE_TIME;
- private static final DateTimeFormatter humanDateFormatter =
+ private static final DateTimeFormatter humanDateTimeFormatter =
DateTimeFormatter.ofLocalizedDateTime(FormatStyle.LONG, FormatStyle.SHORT);
+ private static final DateTimeFormatter htmlDateFormatter =
+ DateTimeFormatter.ISO_LOCAL_DATE;
+
+ private static final DateTimeFormatter humanDateFormatter =
+ DateTimeFormatter.ofLocalizedDate(FormatStyle.LONG);
+
private static final int pageKeyBytes = 32;
protected static final JsonProvider jsonProvider = JsonProvider.provider();
@@ -331,7 +338,7 @@ public abstract class PostResource {
if (x == null) {
return null;
}
- return humanDateFormatter.format(x);
+ return humanDateTimeFormatter.format(x);
}
@TemplateExtension
@@ -340,6 +347,24 @@ public abstract class PostResource {
if (x == null) {
return null;
}
+ return htmlDateTimeFormatter.format(x);
+ }
+
+ @TemplateExtension
+ @CheckForNull
+ static String humanDate(@CheckForNull TemporalAccessor x) {
+ if (x == null) {
+ return null;
+ }
+ return humanDateFormatter.format(x);
+ }
+
+ @TemplateExtension
+ @CheckForNull
+ static String htmlDate(@CheckForNull TemporalAccessor x) {
+ if (x == null) {
+ return null;
+ }
return htmlDateFormatter.format(x);
}