Re: Will we have any option to format 2019 as 元号元年?

Naoto Sato naoto.sato at
Tue Jan 29 16:22:01 UTC 2019

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 

1. Use java.text APIs to format/parse dates, e.g.,

jshell> new SimpleDateFormat("GGGGyyyy年", 
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:


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?

More information about the core-libs-dev mailing list