1. Unlike the original Java .NET add the date of .Add;
import java.util.Date ;
Date date = new Date (); // time taken
System.out.println (Date.toString ());
Calendar Calendar the GregorianCalendar new new = ();
calendar.setTime (DATE);
Calendar.add (Calendar.YEAR,. 1) ; // put back the date pushed back an extra year integer, negative move forward.
Calendar.add (Calendar.DAY_OF_MONTH, 1); // increase next month to date pushed back an integer, negative move forward.
calendar.add (calendar.DATE, 1); // add a day to the next integer date pushed back, forward movement negative.
Calendar.add (calendar.WEEK_OF_MONTH,. 1); // increase the date one month later. integer pushed back, forward movement negative
date = calendar.getTime (); // this time is pushed back the date one day results
System.out.println (date.toString ());
Print results:
Thu Sep 08 15:38:41 CST 2016 // last time the
Sun Sep 17 15:38:41 CST 2017 // change time after
----------------- ----
Disclaimer: this article is the original article CSDN bloggers "Sky786905664", following the CC 4.0 by-sa copyright agreement, reproduced, please attach the original source link and this statement.
Original link: https: //blog.csdn.net/sky786905664/article/details/52472058/