Set Date in a single line

前端 未结 8 2116
一个人的身影
一个人的身影 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

    Calendar has a set() method that can set the year, month, and day-of-month in one call:

    myCal.set( theYear, theMonth, theDay );
    

提交回复
热议问题