Repository: provectus/kafka-ui
Issue: Make message timestamp format configurable
Labels: type/enhancement
good first issue
scope/frontend
status/accepted
status/needs-attention

We changed default date format as requested in #2162.

We need the datetime format configurable on the frontend for the ones who prefer the US format or anything else.

Issue comments:
frontend requirements: #2566
Hey @Haarolean I would like to take this up. Do we want to give the users a limited set of predefined formats, or do we want to give them full flexibility to input a date format which we can use to safely parse any date to?
I think giving them a limited set of formats will be better as we will reduce uncertainty at runtime. And, that set of formats can come from a standard set of formats used around the globe.

We can also do a hybrid, where we provide a few standard formats & also let the user input their own format as text input. To reduce complexity we can parse and validate that date format and provide an appropriate error to the user.

Discussed on discord: needs discussion

there are a few problems with this one:
1. we don't have a design solution for that one, yet
2. Not sure that we'd need this any longer since we implemented a dynamic timestamp format depending on the users' locale (US vs non-US), which looks like it's enough for now


It would be useful if more granular (sub-second, like milliseconds) timestamp information could be displayed too

Pull request review comments:
```suggestion
  /api/info/timestampformat:
```
- that's not related to kafka, let's make it `timestamp.format` for example
- D is a day of the year, we need dd
- also, let's use ddMM as a default one instead of MMdd

Updated PR please check
Updated PR please check
nice

Patch that resolved the issue:
diff --git a/kafka-ui-api/src/main/java/com/provectus/kafka/ui/controller/InfoController.java b/kafka-ui-api/src/main/java/com/provectus/kafka/ui/controller/InfoController.java
new file mode 100644
index 00000000000..66e5d70bd33
--- /dev/null
+++ b/kafka-ui-api/src/main/java/com/provectus/kafka/ui/controller/InfoController.java
@@ -0,0 +1,25 @@
+package com.provectus.kafka.ui.controller;
+
+import com.provectus.kafka.ui.api.TimeStampFormatApi;
+import com.provectus.kafka.ui.model.TimeStampFormatDTO;
+import lombok.RequiredArgsConstructor;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.beans.factory.annotation.Value;
+import org.springframework.http.ResponseEntity;
+import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.server.ServerWebExchange;
+import reactor.core.publisher.Mono;
+
+@RestController
+@RequiredArgsConstructor
+@Slf4j
+public class InfoController extends AbstractController implements TimeStampFormatApi {
+
+  @Value("${timestamp.format:dd.MM.YYYY HH:mm:ss}")
+  private String timeStampFormat;
+
+  @Override
+  public Mono<ResponseEntity<TimeStampFormatDTO>> getTimeStampFormat(ServerWebExchange exchange) {
+    return Mono.just(ResponseEntity.ok(new TimeStampFormatDTO().timeStampFormat(timeStampFormat)));
+  }
+}
diff --git a/kafka-ui-contract/src/main/resources/swagger/kafka-ui-api.yaml b/kafka-ui-contract/src/main/resources/swagger/kafka-ui-api.yaml
index 63f313e2ac1..f7c7fa1ec13 100644
--- a/kafka-ui-contract/src/main/resources/swagger/kafka-ui-api.yaml
+++ b/kafka-ui-contract/src/main/resources/swagger/kafka-ui-api.yaml
@@ -1748,7 +1748,19 @@ paths:
                 $ref: '#/components/schemas/PartitionsIncreaseResponse'
         404:
           description: Not found
-
+  /api/info/timestampformat:
+    get:
+      tags:
+        - TimeStampFormat
+      summary: getTimeStampFormat
+      operationId: getTimeStampFormat
+      responses:
+        200:
+          description: OK
+          content:
+            application/json:
+              schema:
+                $ref: '#/components/schemas/TimeStampFormat'
 components:
   schemas:
     ErrorResponse:
@@ -2351,6 +2363,12 @@ components:
         name:
           type: string
 
+    TimeStampFormat:
+      type: object
+      properties:
+        timeStampFormat:
+          type: string
+
     TopicMessageConsuming:
       type: object
       properties:


Test patch: