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

前端 未结 7 1839
天命终不由人
天命终不由人 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:34

    raduce 1 month of JDF

    Date dateTo = new SimpleDateFormat("yyyy/MM/dd").parse(jdfMeTo.getJulianDate());
            Calendar cal = Calendar.getInstance();
            cal.setTime(dateTo);
            cal.add(Calendar.MONTH, -1);
            Date dateOf = cal.getTime();
            Log.i("dateOf", dateOf.getTime() + "");
            jdfMeOf.setJulianDate(cal.get(Calendar.DAY_OF_YEAR), cal.get(Calendar.DAY_OF_MONTH), 
            cal.get(Calendar.DAY_OF_WEEK_IN_MONTH));
    
    0 讨论(0)
提交回复
热议问题