I feel that it seems quite likely that the Western calendar and the Japanese calendar will be displayed side by side. "Yyyy (ggge)" year "mm" month "dd" day "" in Excel is output in Java.
JapaneseDate japdate = JapaneseDate.now(); DateTimeFormatter dtf1 = DateTimeFormatter.ofPattern("yyyy"); DateTimeFormatter dtf2 = DateTimeFormatter.ofPattern("'('Gyy')Year'MM'Month'dd'Day'"); System.out.println(LocalDate.from(japdate).format(dtf1) + japdate.format(dtf2));
And I think it's probably right. 2017/01/17 added ↓ It wasn't there (sweat)
JapaneseDate japdate = JapaneseDate.now(); DateTimeFormatter dtf3 = DateTimeFormatter.ofPattern("uuuu'('Gyy')Year'MM'Month'dd'Day'"); System.out.println(japdate.format(dtf3));
There is a pattern letter "u", and if you use that, you can go in one shot. It has evolved properly. 2017/01/17 added ↑
Locale loc = new Locale("ja", "JP", "JP"); Calendar cal = Calendar.getInstance(loc); SimpleDateFormat sdf1 = new SimpleDateFormat("yyyy"); SimpleDateFormat sdf2 = new SimpleDateFormat("'('GGGGyyyy')Year'MM'Month'dd'Day'", loc); System.out.println(sdf1.format(cal.getTime()) + sdf2.format(cal.getTime()));
So, it should be right for the time being.
By passing a Japanese locale to getInstance of Calendar, you can return the Japanese Imperial Calendar (java.util.Japanese ImperialCalendar) instead of the Gregorian Calendar (java.util.GregorianCalendar), so it corresponds to the so-called Japanese era. The story that will be possible. I think there was a story that it shouldn't be used easily because the interpretation of the boundary of the era is delicate, but basically I understand that there is no problem if the latest date is given.
However, it's kind of unpleasant to pass a string to the constructor of this locale, so I simply pass Japan explicitly.
Locale loc = Locale.JAPAN; Calendar cal = Calendar.getInstance(loc);
So, I thought it was good, but this does not return the Japanese Empire Calendar. The reason is that Locale.JAPAN.getVariant () does not return "JP"?
Is this something like that? Something strange?