Java - Create the formatter using a pattern

Description

Create the formatter using a pattern

Demo

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

public class Main {
  public static void main(String[] args) {
    LocalDate ld = LocalDate.of(2018, 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  w  ww. j  a v  a  2 s  . c o  m*/
  }
}

Result

Related Topic