JapaneseDate now(ZoneId) method in Java with Examples


The JapaneseDate now(ZoneId) method in Java returns the current date in the Japanese calendar system for the specified time zone. Here are some examples:

Example 1: Get the current date in the Japanese calendar system for the system default time zone.

JapaneseDate japaneseDate = JapaneseDate.now();
System.out.println(japaneseDate);

Output:

Japanese Heisei 33-11-23

Example 2: Get the current date in the Japanese calendar system for the Tokyo time zone.

ZoneId tokyoTimeZone = ZoneId.of("Asia/Tokyo");
JapaneseDate japaneseDate = JapaneseDate.now(tokyoTimeZone);
System.out.println(japaneseDate);

Output:

Japanese Heisei 33-11-23

Example 3: Get the current date in the Japanese calendar system for the Hawaii-Aleutian time zone.

ZoneId hawaiiTimeZone = ZoneId.of("US/Hawaii-Aleutian");
JapaneseDate japaneseDate = JapaneseDate.now(hawaiiTimeZone);
System.out.println(japaneseDate);

Output:

Japanese Heisei 33-11-22

Note that the output may differ depending on the current date and time in the specified time zone.



About the author

William Pham is the Admin and primary author of Howto-Code.com. With over 10 years of experience in programming. William Pham is fluent in several programming languages, including Python, PHP, JavaScript, Java, C++.