DynamicYearLocalizer
class DynamicYearLocalizer(options: DynamicYearOptions = DynamicYearOptions(), locale: PlatformLocale = getDefaultLocale()) : PolyglotReferenceValueLocalizer<Int> (source)
Localizes a year dynamically (either absolute or relative to a Zoned<Instant> reference point).
This class chooses between formatting with a RelativeYearLocalizer (if the difference is within the configured range), or falls back to absolute formatting via YearLocalizer.
As this class implements PolyglotReferenceValueLocalizer, it allows to use localizeAsFlow.
Because kotlinx-datetime doesn't provide a standard type for a year, there is no extension function equivalent for one-off localizations.
Examples:
last year1 year agoin 5y20262026 AD
See also
Constructors
Link copied to clipboard
constructor(options: DynamicYearOptions = DynamicYearOptions(), locale: PlatformLocale = getDefaultLocale())
Functions
Link copied to clipboard
fun <T> PolyglotReferenceValueLocalizer<T>.localizeAsFlow(value: T, clock: Clock = Clock.System, maxTick: Duration? = null): Flow<String>