My code is
ZonedDateTime zoned = ZonedDateTime.now();
DateTimeFormatter pattern = DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM).withLocale(Locale.forLanguageTag("ja-JP"));
System.out.println(zoned.format(pattern));
And the output is 2022/06/13, which is fine. But when I change the locale to en-US, the date is Jun 13, 2022. I want to have all locale-based date to only have numbers and slashes, like 2022/06/13, 06/13/2022. How can I do that?
3/4/5has different meaning to different people in different locations). If you're formatting the date for "internal" representation (ie for API calls etc), then you should really be using a ISO standard format - just sayingDateTimeFormatterBuilder.getLocalizedDateTimePattern(), identify the order ofy,Manddand manually replaceyywith eitheryoryyyy.