Set Date in a single line

前端 未结 8 2246
一个人的身影
一个人的身影 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条回答
  •  渐次进展
    2021-01-31 02:16

    This is yet another reason to use Joda Time

    new DateMidnight(2010, 3, 5)
    

    DateMidnight is now deprecated but the same effect can be achieved with Joda Time DateTime

    DateTime dt = new DateTime(2010, 3, 5, 0, 0);
    

提交回复
热议问题