Removing time from a Date object?

前端 未结 19 1203
余生分开走
余生分开走 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:59

    You can write that for example:

    private Date TruncarFecha(Date fechaParametro) throws ParseException {
        String fecha="";
        DateFormat outputFormatter = new SimpleDateFormat("MM/dd/yyyy");
        fecha =outputFormatter.format(fechaParametro);
        return outputFormatter.parse(fecha);
    }
    

提交回复
热议问题