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 ww  w  .j av  a2s .com
  }
}

Result

Related Topic