Frameworkで小細工をしているようで、MSの去年10月の記事では、「gy年」で「元年」となるとある。
引用 (Handling a new era in the Japanese calendar in .NET)
When run after the servicing update is released, the .NET formatting
routine converts year 1 to Gannen only if the custom date and time
format string includes “y年” or “y’年'”, as the output from the example
illustrates.
とりあえず、PowerShellで動かしてみた。
結果は、フォーマットにシングルコートを付けると「元年」となるようだ。
Aは、シングルコートなし
gy年
Bは、シングルコートあり
gy'年'
Src
$Cal = New-Object cultureinfo("ja-jp", $true)
$Cal.DateTimeFormat.Calendar = New-Object System.Globalization.JapaneseCalendar
([datetime]"2019/5/1").ToString("gy年M月d日", $Cal) # A
([datetime]"2019/5/1").ToString("gy'年'M月d日", $Cal) # B
([datetime]"1989/5/1").ToString("gy年M月d日", $Cal) # A
([datetime]"1989/5/1").ToString("gy'年'M月d日", $Cal) # B
結果
平成31年5月1日
平成31年5月1日
平成1年5月1日
平成元年5月1日
新元号対応で、レジストリーを弄ってないので、2019年5月1日は、平成31年のまま
本日の河上選手:戸田 2日目
11R 4号艇 5号艇が前付で、1コースまで入り5コース進入
1Mで6号艇に巻かれて5着