Hi Naoto-san, Thank you to introduce the workarounds! It's surprising that SimpleDateFormat have supportted Gannen :)
2019年1月30日(水) 1:22 Naoto Sato <naoto.s...@oracle.com>: > Hi Kishida-san, > > Currently we don't have a plan to support Gannen in java.time for > formatting/parsing Japanese calendar dates. Here are a couple of > workarounds: > > 1. Use java.text APIs to format/parse dates, e.g., > > jshell> new SimpleDateFormat("GGGGyyyy年", > Locale.forLanguageTag("ja-JP-u-ca-japanese")).format(new > Calendar.Builder().setDate(2019, Calendar.MAY, 1).build().getTime()) > $3 ==> "元号元年" > > 2. For java.time API, use > DateTimeFormatterBuilder.appendText(TemporalField, Map<Long, String>) to > map the 1 to "元". Following issue demonstrates how to do it: > > https://bugs.openjdk.java.net/browse/JDK-8042131 > > HTH, > Naoto > > On 1/29/19 4:21 AM, kishida naoki wrote: > > As you know, Japanese government have a plan to change the era on May. > > It will be the first year of the new era. > > In practice, we describe the first year as "元年" not as "1年" > > > > Now DateTimeFormatter with `G` output the era. > > `DateTimeFormatter.ofPattern("Gy年").format(JapaneseDate.of(2019, 5, 2))` > > output `元号1年` > > > > Do you have any plan to have a option to format it as `元号元年` or already > > implemented? > > > -- きしだ なおき