Commit 12a958d 1 parent b6e68c8 commit 12a958d Copy full SHA for 12a958d
File tree 3 files changed +35
-7
lines changed
user-interface/src/main/java/life/qbic/datamanager/views
3 files changed +35
-7
lines changed Original file line number Diff line number Diff line change
1
+ package life .qbic .datamanager .views .general ;
2
+
3
+ import java .time .Instant ;
4
+ import java .time .ZoneId ;
5
+ import java .time .format .DateTimeFormatter ;
6
+
7
+ /**
8
+ * <b>Date Time Rendering</b>
9
+ *
10
+ * <p>A collection of utility methods to render instants in a harmonised way throughout the
11
+ * application.</p>
12
+ *
13
+ * @since 1.7.0
14
+ */
15
+ public class DateTimeRendering {
16
+
17
+ private static final String DATE_TIME_PATTERN = "dd.MM.yyyy HH:mm" ;
18
+
19
+ /**
20
+ * Formats an {@link Instant} in "dd.MM.yyyy HH:mm".
21
+ *
22
+ * @param instant the instant to format
23
+ * @return the formatted instant
24
+ * @since 1.7.0
25
+ */
26
+ public static String simple (Instant instant ) {
27
+ var formatter = DateTimeFormatter .ofPattern (DATE_TIME_PATTERN ).withZone (ZoneId .systemDefault ());
28
+ return formatter .format (instant );
29
+ }
30
+
31
+ }
Original file line number Diff line number Diff line change 24
24
import life .qbic .application .commons .SortOrder ;
25
25
import life .qbic .datamanager .views .account .UserAvatar .UserAvatarGroupItem ;
26
26
import life .qbic .datamanager .views .general .Card ;
27
+ import life .qbic .datamanager .views .general .DateTimeRendering ;
27
28
import life .qbic .datamanager .views .general .PageArea ;
28
29
import life .qbic .datamanager .views .general .Tag ;
29
30
import life .qbic .datamanager .views .general .Tag .TagColor ;
@@ -200,7 +201,7 @@ public ProjectOverviewItem(ProjectOverview projectOverview) {
200
201
Span header = createHeader (projectOverview .projectCode (), projectOverview .projectTitle ());
201
202
add (header );
202
203
Span lastModified = new Span (
203
- String .format ("Last modified on %s" , projectOverview .lastModified ()));
204
+ String .format ("Last modified on %s" , DateTimeRendering . simple ( projectOverview .lastModified () )));
204
205
lastModified .addClassName ("tertiary" );
205
206
add (lastModified );
206
207
projectDetails .addClassName ("details" );
Original file line number Diff line number Diff line change 37
37
import life .qbic .datamanager .views .Context ;
38
38
import life .qbic .datamanager .views .TagFactory ;
39
39
import life .qbic .datamanager .views .account .UserAvatar .UserAvatarGroupItem ;
40
+ import life .qbic .datamanager .views .general .DateTimeRendering ;
40
41
import life .qbic .datamanager .views .general .CollapsibleDetails ;
41
42
import life .qbic .datamanager .views .general .DetailBox ;
42
43
import life .qbic .datamanager .views .general .Heading ;
@@ -200,11 +201,6 @@ private static List<? extends UserScopeStrategy> loadWriteScope(Section[] sectio
200
201
return Arrays .stream (sections ).map (WriteScopeStrategy ::new ).toList ();
201
202
}
202
203
203
- private String formatDate (Instant date ) {
204
- var formatter = DateTimeFormatter .ofPattern (DATE_TIME_PATTERN ).withZone (ZoneId .systemDefault ());
205
- return formatter .format (date );
206
- }
207
-
208
204
public void setContext (Context context ) {
209
205
this .context = Objects .requireNonNull (context );
210
206
var projectId = context .projectId ()
@@ -556,7 +552,7 @@ private void buildHeaderSection(ProjectOverview projectOverview) {
556
552
sectionContent .add (createTags (projectOverview ));
557
553
558
554
header .setSectionNote (new SectionNote (
559
- "Last modified on %s" .formatted (formatDate (projectOverview .lastModified ()))));
555
+ "Last modified on %s" .formatted (DateTimeRendering . simple (projectOverview .lastModified ()))));
560
556
headerSection .setHeader (header );
561
557
headerSection .setContent (sectionContent );
562
558
}
You can’t perform that action at this time.
0 commit comments