How to reduce one month from current date and stored in date variable using java?

前端 未结 7 2005
天命终不由人
天命终不由人 2020-12-24 04:32

How to reduce one month from current date and want to sore in java.util.Date variable im using this code but it\'s shows error in 2nd line

 java         


        
7条回答
  •  清歌不尽
    2020-12-24 05:17

    Using JodaTime :

    Date date = new DateTime().minusMonths(1).toDate();
    

    JodaTime provides a convenient API for date manipulation.

    Note that similar Date API will be introduced in JDK8 with the JSR310.

提交回复
热议问题