Getting yesterday - The method getDate() from the type Date is deprecated

后端 未结 5 637
面向向阳花
面向向阳花 2020-12-20 15:56

I try to get the date of yesterday. So I write the next function:

public  String getYestrday() {
    DateFormat dateFormat = new SimpleDateFormat(\"yyyy-MM-d         


        
5条回答
  •  梦毁少年i
    2020-12-20 16:41

    you can use Calendar class to do the same task:

    Calendar c = new Calendar();
    //c.add(Calendar.DAY_OF_MONTH, -1);
    Date d = c.getTime();
    

提交回复
热议问题