How to get a Date object from year,month and day?

前端 未结 5 1147
孤街浪徒
孤街浪徒 2021-01-23 07:14

When I used the following code, the Date Object was wrong.

Date date = new Date(day.getYear(), day.getMonth(), day.getDay());

Can

5条回答
  •  孤城傲影
    2021-01-23 07:44

    you should use getDate() instead of getDay() method to get the day because getDay() return the day of week not the day of month

提交回复
热议问题