xxxxxxxxxx
LocalDate localDate = LocalDate.now();//For reference
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("dd LLLL yyyy");
String formattedString = localDate.format(formatter);
xxxxxxxxxx
Using a custom pattern
DateTimeFormatter customFormat = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");;
String formattedString = currentDateTime.format(customFormat);
System.out.println(formattedString); //2022-12-09 18:25:58