You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
In the java.time classes, the DateTimeFormatter class offers ofLocalized… methods where localized text is generated to represent the date-time object's value, guided by the specified FormatStyle and Locale.
relativeTime Display names for an instance of the field that is a counted number of units in the past or the future relative to the current instance; this needs plural forms. In English, data is provided for year, quarter, month, week, day, specific days of the week, ,hour, minute, and second.
The text was updated successfully, but these errors were encountered:
This branch has work I started on this problem. The data is there (from Joda-Time) but I haven't got the time to fix the code. If anyone reading this wants to attempt a PR, please add a comment.
In the java.time classes, the
DateTimeFormatter
class offersofLocalized…
methods where localized text is generated to represent the date-time object's value, guided by the specifiedFormatStyle
andLocale
.Example:
It would be nice if the
Seconds
,Minutes
,Hours
,Days
,Weeks
,Months
, andYears
classes in ThreeTen-Extra could also generate localized text.Someone asked for such localized text on Stack Overflow: Are there standard ways to accomplish localized date components on Android such as 1s, 1m, 1h, 1d, 1w, 1week, etc.
The example given in that posting, for a date component in English and a Spanish localization:
English (en):
Spanish (es):
Possible solution: CLDR
According to JEP 252, the Unicode Consortium's Common Locale Data Repository (CLDR) has been bundled with Java 8 and later, at least in OpenJDK.
It seems like these values needed for this feature might be found in the CLDR if I am correctly reading the
<relativeTime>
item in section 3, Calendar Fields, of Unicode Technical Standard #35 UNICODE LOCALE DATA MARKUP LANGUAGE (LDML) PART 4: DATES:The text was updated successfully, but these errors were encountered: