Set time to 00:00:00

前端 未结 12 2152
时光说笑
时光说笑 2020-11-29 20:04

I have a problem resetting hours in Java. For a given date I want to set the hours to 00:00:00.

This is my code :

/**
     * Resets milliseconds, se         


        
12条回答
  •  独厮守ぢ
    2020-11-29 20:53

    You can either do this with the following:

    Calendar cal = Calendar.getInstance();
    cal.set(year, month, dayOfMonth, 0, 0, 0);
    Date date = cal.getTime();
    

提交回复
热议问题