Here you can find the source of formatByLocale(Date date, Locale locale)
public static String formatByLocale(Date date, Locale locale)
//package com.java2s; //License from project: Creative Commons License import java.time.ZoneId; import java.time.ZonedDateTime; import java.time.format.DateTimeFormatter; import java.time.format.FormatStyle; import java.util.Date; import java.util.Locale; public class Main { public static String formatByLocale(Date date, Locale locale) { return formatByLocale(parseToZonedDateTime(date), locale); }//from w ww . j a v a 2 s .c o m public static String formatByLocale(ZonedDateTime zonedDateTime, Locale locale) { DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofLocalizedDateTime(FormatStyle.MEDIUM) .withLocale(locale); return zonedDateTime.format(dateTimeFormatter); } public static ZonedDateTime parseToZonedDateTime(String dateString, String pattern) { return ZonedDateTime.parse(dateString, DateTimeFormatter.ofPattern(pattern)); } public static ZonedDateTime parseToZonedDateTime(Date date) { return date.toInstant().atZone(getZoneId()); } private static ZoneId getZoneId() { return ZoneId.systemDefault(); } }