且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

简单日期格式.返回错误日期的格式

更新时间: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);