Package org.patternfly.component.timestamp


package org.patternfly.component.timestamp
Provides a timestamp component for displaying dates and times in various formats.

The timestamp component renders a date/time value with support for predefined formats (short, medium, long, full), custom formatting options, UTC display, display suffixes, and custom content. It wraps the JavaScript Intl.DateTimeFormat API for locale-aware formatting.

Key Classes

Usage

Create timestamps with various formats:

 import static org.patternfly.component.timestamp.Timestamp.timestamp;
 import org.patternfly.component.timestamp.TimestampFormat;

 // Default timestamp (current date/time)
 Timestamp now = timestamp();

 // UTC display
 Timestamp utc = timestamp().utc(true);

 // With predefined date and time formats
 Timestamp formatted = timestamp()
         .dateFormat(TimestampFormat.full)
         .timeFormat(TimestampFormat._short);

 // With a display suffix
 Timestamp withSuffix = timestamp()
         .dateFormat(TimestampFormat.medium)
         .timeFormat(TimestampFormat._short)
         .displaySuffix("US Eastern");

Create a timestamp with custom format options:

 import static org.patternfly.component.timestamp.Timestamp.timestamp;
 import org.patternfly.component.timestamp.CustomFormat;
 import org.patternfly.component.timestamp.DateTimeFormatOptions.*;

 Timestamp custom = timestamp()
         .customFormat(CustomFormat.create()
                 .weekday(Weekday._short)
                 .day(Day.numeric)
                 .month(Month._short)
                 .year(Year._2digit)
                 .hour(Hour._2digit));
See Also: