Class RelativeTime

java.lang.Object
com.vaadin.flow.component.Component
com.flowingcode.vaadin.addons.relativetime.RelativeTime
All Implemented Interfaces:
AttachNotifier, DetachNotifier, HasElement, HasStyle, Serializable

@Tag("relative-time") @NpmPackage(value="@github/relative-time-element", version="5.0.0") @JsModule("@github/relative-time-element") public class RelativeTime extends Component
Renders a date/time as a human-readable relative string ("4 hours ago", "in 2 weeks") that updates in the browser as time passes and is shown in the viewer's local time.

Thin wrapper around the @github/relative-time-element custom element. The Java setters write the corresponding attributes on the element and the browser does all the formatting and updating work.

Client-side rendering. The rendered text reflects the viewer's clock and locale, not the server's. There is no server-side API to read the displayed string; the string lives only in the DOM.

Attributes, not properties. Setters write HTML attributes (setAttribute), not DOM properties, because the upstream element is attribute-driven and its kebab-case attribute names match the upstream docs one-to-one. setProperty would force diverging camelCase names.

LocalDateTime and LocalDate inputs are interpreted in the server's default zone before being serialised as an instant.

See Also: