[threeten-dev] era formatting and era.getText(...)

Stephen Colebourne scolebourne at joda.org
Wed Jan 16 16:02:56 PST 2013


Webrev looks fine.

Parsing can work as far as the context. The addCalendrical() method
will accept a Chrono.

Stephen


On 16 January 2013 22:36, Xueming Shen <xueming.shen at oracle.com> wrote:
> It appears the Era formatting and Era.getText(...) never works
> as expected (DateTimeTextProvider does not suport Era field),
> so following code gives you numeric value of each era.
>
>        Locale locale = Locale.JAPANESE;
>
>         ChronoLocalDate<JapaneseChrono> cld =
> JapaneseChrono.INSTANCE.date(LocalDateTime.now());
>         DateTimeFormatter fmt = new DateTimeFormatterBuilder()
>                               .appendLocalized(FormatStyle.FULL, null,
> JapaneseChrono.INSTANCE)
>                               .toFormatter(locale);
>
>         System.out.println(cld);
>         System.out.println(fmt.print(cld));
>
> System.out.println(DateTimeFormatters.pattern("GGGG").withLocale(locale).print(cld));
>
>
>         //for (Era era : ISOChrono.INSTANCE.eras()) {
>         for (Era era : JapaneseChrono.INSTANCE.eras()) {
>             System.out.printf("%s  -> %s%n", era.toString(),
> era.getText(TextStyle.FULL, locale));
>         }
>
> Here is the webrev to make it work
>
> http://cr.openjdk.java.net/~sherman/jdk8_threeten/era/
>
> DateTimeTextProvider can be consolidated later, probably goes to
> CalendarDateUtilities directly...
>
> Parser still does not work as we don't have a "chrono" in parser context,
> yet.
>
> -Sherman


More information about the threeten-dev mailing list