How to add days to java.sql.date?

前端 未结 5 2659
猫巷女王i
猫巷女王i 2021-02-20 07:16

Here is my program, I tried

java.sql.Date logicalDate;
Calendar c = Calendar.getInstance(); 
c.setTime(logicalDate); 
c.add(Calendar.DATE, 1);

5条回答
  •  半阙折子戏
    2021-02-20 07:34

    Calendar#getTime returns a java.util.Date representation of the Calendar. You really need to use Calendar#getTimeInMillis instead

    java.sql.Date startDate= new java.sql.Date(c.getTimeInMillis())
    

提交回复
热议问题