[Java] Output by FormatStyle of DateTimeFormatter

Locale Japan

        Locale locale = Locale.JAPAN;
        LocalDateTime now = LocalDateTime.now();

Output program

Format with ofLocalizedDateTime.

        
        System.out.println(
                now.format(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.FULL).withLocale(locale))
        );
        System.out.println(
                now.format(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.LONG).withLocale(locale))
        );
        System.out.println(
                now.format(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM).withLocale(locale))
        );
        System.out.println(
                now.format(DateTimeFormatter.ofLocalizedDateTime(FormatStyle.SHORT).withLocale(locale))
        );

Execution result (from top, FULL, LONG, MEDIUM, SHORT)

java.time.DateTimeException: Unable to extract ZoneId from temporal 2019-07-01T07:58:21.538531
java.time.DateTimeException: Unable to extract ZoneId from temporal 2019-07-01T07:58:21.538531
2019/07/01 7:59:30
2019/07/01 7:59

Locale America

Execution result (from top, FULL, LONG, MEDIUM, SHORT)

java.time.DateTimeException: Unable to extract ZoneId from temporal 2019-07-01T07:58:21.538531
java.time.DateTimeException: Unable to extract ZoneId from temporal 2019-07-01T07:58:21.538531
Jul 1, 2019, 7:57:26 AM
7/1/19, 7:57 AM

Recommended Posts

[Java] Output by FormatStyle of DateTimeFormatter
Output of the book "Introduction to Java"
[Java] output, variables
[Java] Overview of Java
[Java] Dynamic method call by reflection of enum (enum)
[Note] Java: Speed of List processing by purpose
About Java log output
[Java] Basic summary of Java not covered by Progate ~ Part 1 ~
Expired collection of java
Predicted Features of Java
Format of the log output by Tomcat itself in Tomcat 8
Java formatted output [Notes]
NIO.2 review of java
Summary of revisions (new era) support by Java version
Comparative study of TLS Cipher Suite supported by Java 8
History of Java annotation
java (merits of polymorphism)
Sample code for log output by Java + SLF4J + Logback
NIO review of java
[Java] Three features of Java
Output in multiples of 3
Summary of Java support 2018
[Java] How to display the day of the week acquired by LocalDate, DateTimeformatter in Japanese
[Note] Java Output of the sum of odd and even elements
[Java] Basic summary of Java not covered by Progate ~ Part 2 · List ~
Recommendation of set operation by Java (and understanding of equals and hashCode)
Traps brought about by the default implementation of the Java 8 interface
Summary of values returned by the Spliterator characteristics method #java
About an instance of java
[Java] Beginner's understanding of Servlet-②
[Java] Practice of exception handling [Exception]
[Java11] Stream Summary -Advantages of Stream-
Basics of character operation (java)
[Java] Creation of original annotation
4th day of java learning
[Java] Beginner's understanding of Servlet-①
Java end of month plusMonths
[Java] Summary of regular expressions
[Java] Summary of operators (operator)
[Java] Implementation of Faistel Network
[Java] Comparator of Collection class
Object-oriented summary by beginners (Java)
Java standard log output sample
Summary of Java language basics
[Java] Summary of for statements
Summary of Java Math class
Enumeration of all combinations Java
java (inheritance of is-a principle)
Implementation of gzip in java
Advantages and disadvantages of Java
Benefits of Java static method
Summary of 2020 programming learning output
[Java] Summary of control syntax
Implementation of tri-tree in Java
Summary of java error processing
[Java] Summary of design patterns
[Java] Summary of mathematical operations
The story of not knowing the behavior of String by passing Java by reference
I tried the input / output type of Java Lambda ~ Map edition ~
Read the first 4 bytes of the Java class file and output CAFEBABE
Concatenate strings returned by methods of multiple objects in Java Stream