How to format a date by any locale obtained from language tag with java time?
问题 I want to get a date as string and a language tag and based on that to parse the string by the locale format. This is what I've done so far: public static String formatDateByLocale(String date, String languageTag) { Locale locale = Locale.forLanguageTag(languageTag); String datePattern = DateTimeFormatterBuilder.getLocalizedDateTimePattern(FormatStyle.LONG, FormatStyle.LONG, Chronology.ofLocale(locale), locale); DateTimeFormatter targetFormat = DateTimeFormatter.ofPattern(datePattern)