I need to confirm the Japanese date entered by the user.
Let's say the user selects ERA→ Enter DOB as a format YY - MM - dd.
On the server side, I get input dateand ERAselected by the user.
Now I need to check the entered date with the selected ERA if the date falls in the period of a specific ERA or not.
I know that there is support in the Java Calendar API, there is also a class JapaneseImperialCalendar, but I cannot figure out how to use it, although it uses it internally.
This is what I have done so far.
public static void main(String[] args) {
Locale locale = new Locale("ja", "JP", "JP");
Calendar now = Calendar.getInstance(locale);
System.out.println(now.get(Calendar.ERA));
Map<String, Integer> names = now.getDisplayNames(Calendar.ERA, Calendar.LONG, locale);
System.out.println(names);
System.out.printf("It is year %tY of the current era%n", now);
System.out.printf("The calendar class is: %s%n", now.getClass().getName());
}
Output
4
{??=3, ??=4, ??=2, ??=1, ??=0}
It is year 0026 of the current era
The calendar class is: java.util.JapaneseImperialCalendar
Suppose user logs in, selected ERA SHOWA, expected period1926–1989
YY MM DD
34 05 28 // which is valid date
again
YY MM DD
62 12 28
Therefore, you need to create some logic to check the user input date using ERA