Removing time from a Date object?

前端 未结 19 1258
余生分开走
余生分开走 2020-12-15 02:26

I want to remove time from Date object.

DateFormat df;
String date;
df = new SimpleDateFormat(\"dd/MM/yyyy\");
d = eventList.get(0).getStartDate         


        
19条回答
  •  执笔经年
    2020-12-15 02:51

    You can also manually change the time part of date and format in "dd/mm/yyyy" pattern according to your requirement.

      public static Date getZeroTimeDate(Date changeDate){
    
            Date returnDate=new Date(changeDate.getTime()-(24*60*60*1000));
            return returnDate;
        }
    

    If the return value is not working then check for the context parameter in web.xml. eg.

        
            javax.faces.DATETIMECONVERTER_DEFAULT_TIMEZONE_IS_SYSTEM_TIMEZONE
            true
        
    

提交回复
热议问题