Here you can find the source of formatDate(String inPattern, LocalDateTime inTime)
public static String formatDate(String inPattern, LocalDateTime inTime)
//package com.java2s; //License from project: Open Source License import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; import java.time.format.DateTimeFormatterBuilder; import java.util.HashMap; import java.util.Locale; import java.util.Map; public class Main { private static final Map<String, DateTimeFormatter> DATETIMEFORMATTERS = new HashMap<>(); public static String formatDate(String inPattern, LocalDateTime inTime) { return formatDate(inPattern, Locale.getDefault(), inTime); }/* w ww .j ava 2 s . c om*/ public static String formatDate(String inPattern, Locale inLocale, LocalDateTime inTime) { if (inPattern == null || inTime == null) { return null; } DateTimeFormatter theDtf = DATETIMEFORMATTERS.get(inPattern); if (theDtf == null) { DATETIMEFORMATTERS.put(inPattern, theDtf = new DateTimeFormatterBuilder().appendPattern(inPattern).toFormatter(inLocale)); } return theDtf.format(inTime); } }