Java Data Type How to - Format date in French locale with FULL style








Question

We would like to know how to format date in French locale with FULL style.

Answer

import java.time.ZoneId;
import java.time.ZonedDateTime;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;
import java.util.Locale;
/*from   w  w  w .j av  a2  s  .c o m*/
public class Main {

  public static void main(String[] args) {
    ZonedDateTime zonedDateTime = ZonedDateTime.of(2013, 1, 19, 0, 0, 0, 0,
        ZoneId.of("Europe/Paris"));

    DateTimeFormatter longDateTimeFormatter = DateTimeFormatter
        .ofLocalizedDateTime(FormatStyle.FULL, FormatStyle.FULL).withLocale(
            Locale.FRENCH);
    System.out.println(longDateTimeFormatter.getLocale()); // fr
    System.out.println(longDateTimeFormatter.format(zonedDateTime)); 
    
  }
}

The code above generates the following result.