0

i used the class localDAte in a method like this :

public String dateR(int ageR) {
        LocalDate dateR= dateN.plusYears(ageR);
        return dateR.toString();
}

and it gives me the date in "yyyy-mm-dd" format however i want it in "dd-mm-yyyy" format

i want the result date in "dd-mm-yyyy" format

dhiya
  • 1
  • 1
  • `return dateR.format(DateTimeFormatter.ofPattern("dd-MM-uuuu", Locale.ROOT));`. Or for many purposes even better `dateR.format(DateTimeFormatter.ofLocalizedDate(FormatStyle.SHORT))` to get the localized format for the default locale. Under all circumstances extract the formatter into a constant. – Ole V.V. May 04 '23 at 08:58

0 Answers0