Skip to content

Commit cb1d467

Browse files
authored
Cat apis: Fix index creation time to use strict date format (elastic#32510)
With the move to java time, the default formatter used by toString on ZonedDateTime uses optional components for least significant portions of the date. This commit changes the cat indices api to use a strict date time format, which will always output milliseconds, even if they are zero. closes elastic#32466
1 parent b08416b commit cb1d467

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

server/src/main/java/org/elasticsearch/rest/action/cat/RestIndicesAction.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@
3939
import org.elasticsearch.common.Strings;
4040
import org.elasticsearch.common.Table;
4141
import org.elasticsearch.common.settings.Settings;
42+
import org.elasticsearch.common.time.DateFormatters;
4243
import org.elasticsearch.index.Index;
4344
import org.elasticsearch.rest.RestController;
4445
import org.elasticsearch.rest.RestRequest;
@@ -380,7 +381,8 @@ Table buildTable(RestRequest request, Index[] indices, ClusterHealthResponse res
380381
table.addCell(primaryStats.getDocs() == null ? null : primaryStats.getDocs().getDeleted());
381382

382383
table.addCell(indexMetaData.getCreationDate());
383-
table.addCell(ZonedDateTime.ofInstant(Instant.ofEpochMilli(indexMetaData.getCreationDate()), ZoneOffset.UTC));
384+
ZonedDateTime creationTime = ZonedDateTime.ofInstant(Instant.ofEpochMilli(indexMetaData.getCreationDate()), ZoneOffset.UTC);
385+
table.addCell(DateFormatters.forPattern("strict_date_time").format(creationTime));
384386

385387
table.addCell(totalStats.getStore() == null ? null : totalStats.getStore().size());
386388
table.addCell(primaryStats.getStore() == null ? null : primaryStats.getStore().size());

0 commit comments

Comments
 (0)