Set Date in a single line

前端 未结 8 2115
一个人的身影
一个人的身影 2021-01-31 01:55

According to the Java API, the constructor Date(year, month, day) is deprecated. I know that I can replace it with the following code:

Calendar myCa         


        
8条回答
  •  梦毁少年i
    2021-01-31 02:22

    You could use new GregorianCalendar(theYear, theMonth, theDay).getTime():

    public GregorianCalendar(int year, int month, int dayOfMonth)

    Constructs a GregorianCalendar with the given date set in the default time zone with the default locale.

提交回复
热议问题