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
Timestamp- Main timestamp componentTimestampFormat- Predefined format options (short, medium, long, full)CustomFormat- Custom date/time format configurationDateTimeFormatOptions- Options for individual date/time fields
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:
-
ClassDescriptionContainer for all date/time formatting options based on MDN Intl.DateTimeFormat Consolidates all format enums into static inner classes for better organization.Options for day formatting.Options for day period formatting.Options for era formatting.Options for fractional second digits.Options for hour formatting.Options for minute formatting.Options for month formatting.Options for second formatting.Options for time zone name formatting.Options for weekday formatting.Options for year formatting.A marker interface for different formatting options used in the Timestamp component.A timestamp component for displaying date and time values.Enum representing various timestamp formats–for
dateStyleandtimeStyle–based on the Intl.DateTimeFormat API.