Java DateTimeFormatter format the LocalDate in "dd.MM.yyyy-XX" format

PreviousNext

format the LocalDate in "dd.MM.yyyy-XX" format

Parameter:

  • *LocalDate
  • date* to be formatted

Return:

a string representing time in "dd.MM.yyyy-XX" format

//package com.java2s;

import java.time.LocalDate;
import java.time.format.DateTimeFormatter;
import java.time.format.FormatStyle;

import java.util.Locale;

public class Main {
    private static final DateTimeFormatter germanFormatter = DateTimeFormatter.ofLocalizedDate(FormatStyle.MEDIUM)
            .withLocale(Locale.GERMAN);

    /**//    w w   w .  d e   m   o2    s  . c  o m  
     * format the LocalDate in "dd.MM.yyyy-XX" format
     * 
     * @param LocalDate
     *            date to be formatted
     * @return a string representing time in "dd.MM.yyyy-XX" format
     */
    public static String getFormattedDateString(LocalDate date) {
        return germanFormatter.format(date).toString();
    }
}
PreviousNext

Related