首页javadate_timeJava Data Type - 如何创建MEDIUM DateTimeFormatter

Java Data Type - 如何创建MEDIUM DateTimeFormatter

我们想知道如何创建MEDIUM DateTimeFormatter。
import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;

public class Main {

  public static void main(String[] args) {
    DateTimeFormatter dateFormatter = DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM);
    System.out.println(dateFormatter.format(LocalDate.now())); // Current Local Date
    System.out.println(dateFormatter.parse("Jan 19, 2014").getClass().getName()); //java.time.format.Parsed
    System.out.println(dateFormatter.parse("Jan 19, 2014", LocalDate::from)); // Jan 19, 2014

  }
}