更新时间:2023-11-23 23:09:10
试试这个:
Date date=new Date();
// you can assign your return from the function here
LocalDate localDate = date.toInstant().atZone(ZoneId.systemDefault()).toLocalDate();
System.out.println(localDate.getMonthValue());
System.out.println(localDate.getDayOfMonth());
System.out.println(localDate.getYear());
SimpleDateFormat df = new SimpleDateFormat("dd/MM/yyyy");
String formattedDate = df.format(date);
System.out.println("New Date To Show::"+formattedDate);