I tried the new era in Java

Java SE 8 seems to support the new era

Verified with Java SE 8 Update 211 released on April 17, 2019.


DateTimeFormatter dtf = DateTimeFormatter.ofPattern("GGGGy year M month d day")

JapaneseDate jd = JapaneseDate.of(2019, 4, 29);

for (int i = 0; i < 5; i++) {
    System.out.println(dtf.format(jd.plus(i, ChronoUnit.DAYS)));

Execution result

April 29, 2019
April 30, 2019
May 1, 1st year of Reiwa
May 2, 1st year of Reiwa
May 3, 1st year of Reiwa

It became Reiwa. You did it, did not you.

By the way, it's Golden Week soon

I was only concerned about the era, and I completely forgot to call the first year of the new era the "first year." I hope it doesn't cause any trouble.

Have a nice Golden Week.

I tried to support the "first year"


DateTimeFormatter dtf = new DateTimeFormatterBuilder()
        .appendText(ChronoField.ERA, TextStyle.FULL)
        .appendText(ChronoField.YEAR_OF_ERA, Collections.singletonMap(1L, "Former"))

Would you like to make it the Christian era? (Conclusion)

Recommended Posts

I tried the new era in Java
I tried metaprogramming in Java
I tried to implement the Euclidean algorithm in Java
I tried the Java framework "Quarkus"
I tried using JWT in Java
I tried the new era in Java
Java Programming Style Guide for the Java 11 Era
I tried the AutoValue library in Intellij
What's new in Java 8
What's new in Java 9,10,11
A story about the JDK in the Java 11 era
I tried to organize the session in Rails
I tried to implement deep learning in Java
I tried to output multiplication table in Java
I touched on the new features of Java 15
I tried to create Alexa skill in Java
I tried to organize the cases used in programming
I tried to implement Firebase push notification in Java
I tried using Google Cloud Vision API in Java
I made roulette in Java.
# 2 [Note] I tried to calculate multiplication tables in Java.
I tried the new feature profiler of IntelliJ IDEA 2019.2.
I tried to create a Clova skill in Java
I tried Drools (Java, InputStream)
I tried to make a login function in Java
I tried installing the Docker Integration plugin in IntelliJ
I tried the Docker tutorial!
I tried the VueJS tutorial!
I tried using Java REPL
I tried using an extended for statement in Java
I tried the FizzBuzz problem
[Java] I implemented the combination.
I tried passing Java Silver in 2 weeks without knowing Java
~ I tried to learn functional programming in Java now ~
I studied the constructor (java)
I tried to find out what changed in Java 9
I translated [Clone method for Java arrays] as the Clone method in Java arrays.
[Java] ArrayList → Should I specify the size in array conversion?
[JDBC] I tried to access the SQLite3 database from Java.
I tried to summarize the basics of kotlin and java
Object-oriented child !? I tried Deep Learning in Java (trial edition)
I tried to convert a string to a LocalDate type in Java
I tried using Dapr in Java to facilitate microservice development
How to switch Java in the OpenJDK era on Mac
I tried to make a client of RESAS-API in Java
I tried using the CameraX library with Android Java Fragment
I want to simplify the conditional if-else statement in Java
Access the network interface in Java
I sent an email in Java
Apache Camel in the cloud-native era
I created a PDF in Java.
Specify the java location in eclipse.ini
Unzip the zip file in Java
I tried to interact with Java
I tried UDP communication with Java
I tried to explain the method
I wrote Goldbach's theorem in java
I tried putting Domino11 in CentOS7
[Rails] I tried deleting the application
I tried using Java8 Stream API
Parsing the COTOHA API in Java
I made an annotation in Java.