DynamicDateAbsoluteTimeLocalizer

Localizes a LocalDateTime dynamically (either absolute or relative to a Zoned<Instant> reference point).

This class chooses between formatting with a RelativeDateAbsoluteTimeLocalizer (if the difference is within the configured range), or falls back to absolute formatting via LocalDateLocalizer.

So, in essence, the time is always localized absolutely, while the date is dynamic.

Create once and re-use for localizing multiple values with the same options. Use LocalDateTime.localizeDynamicDateAbsoluteTime or LocalDateTime.localizeDynamicDateAbsoluteTimeAsFlow for one-off localizations.

Examples:

  • yesterday at 9:00 AM

  • 1 day ago at 18:00

  • next Sunday at 12:00 PM

  • January 1 2026 at 8 in the morning

  • 1/1/26, 8 PM

See also

Constructors

Link copied to clipboard
constructor(options: DynamicDateAbsoluteTimeOptions, locale: PlatformLocale = getDefaultLocale())

Functions

Link copied to clipboard
open override fun localize(value: LocalDateTime, reference: Zoned<Instant>): TickingValue<String>
Link copied to clipboard
fun <T> PolyglotReferenceValueLocalizer<T>.localize(value: T, clock: Clock = Clock.System): TickingValue<String>

Localizes value by using the given clock's Clock.now as a reference point, rather than passing the reference explicitly.

Link copied to clipboard
fun <T> PolyglotReferenceValueLocalizer<T>.localizeAsFlow(value: T, clock: Clock = Clock.System, maxTick: Duration? = null): Flow<String>

Localizes value by using the given clock's Clock.now as a reference point and returns a Flow that emits updated values based on the underlying TickingValue.nextTick. This function assumes that the given clock moves forward linearly.