Java DateTimeFormatter create from pattern

Description

Java DateTimeFormatter create from pattern

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;

public class Main {
  public static void main(String[] args) {
    LocalDate ld = LocalDate.of(2020, 12, 25);
    String pattern = "'Christmas in' yyyy 'is on' EEEE";
    DateTimeFormatter formatter = DateTimeFormatter.ofPattern(pattern);
    String str = ld.format(formatter);
    System.out.println(str);//from  ww w.j  ava  2  s .  co m
  }
}



PreviousNext

Related