Relative Local Date Localizer
Localizes a LocalDate relative to a Zoned<Instant> reference point.
As this class implements PolyglotReferenceValueLocalizer, it allows to use localizeAsFlow.
Localization prioritizes, based on options:
word style localization (e.g.
yesterday,today,tomorrow, etc.)day of week relative localization (e.g.
this Fridayornext Monday)numeric style (e.g.
in 15 days)
Important note on day of week relative localization: given that this form of localization is sometimes ambiguous, it is bound be the following rules:
last <day-of-week>form is never used, because it could lead to ambiguity (e.g. if the reference is Wednesday, and the output islast Monday, does it mean 2 days ago or 9 days ago?)this <day-of-week>is used when the day in question is in the future and falls in the same week (according to the PlatformLocale)next <day-of-week>is used when the day in question is in the future, falls in the next week (according to the PlatformLocale), and is within 7 days of the reference. This means that,next <day-of-week>can never be produced if the reference point is at a day of week earlier than<day-of-week>(according to the PlatformLocale). As a clarification example, imagine that we are using theen-GBlocale (where the first day of the week is Monday), and the reference is Wednesday. Only the following localizations can be produced using this format:this Thursday(1 day in the future)this Friday(2 days in the future)this Saturday(3 days in the future)this Sunday(4 days in the future)next Monday(5 days in the future)next Tuesday(6 days in the future)next Wednesday(7 days in the future)
Notice how in the example next Thursday cannot be produced because it would be ambiguous (does it mean in 1 day or in 8 days?). In this case it would fall back to the regular numeric relative format (i.e. in 8 days).
Create once and re-use for localizing multiple values with the same options. Use LocalDate.localizeRelative or LocalDate.localizeRelativeAsFlow for one-off localizations.
Examples:
todayyestedaytomorrowthis Mondaynext Fridayin 54 days5 days ago