Java date: add one day, year, month, and date plus 1, date + 1, month + 1, year + 1, and date
System. out. println ("String type" + endDate); // The time when the page is passed to the background is String type SimpleDateFormat sdf = new SimpleDateFormat ("yyyy-MM-dd "); date sDate = sdf. parse (endDate); System. out. println ("String type to Date type" + sDate); // to implement Date + 1, convert String to Date type Format f = new SimpleDateFormat ("yyyy-MM-dd "); system. out. println ("Date end Date:" + f. format (sDate); Calendar c = Calendar. getInstance (); c. setTime (sDate); c. add (Calendar. DAY_OF_MONTH, 1); // use Calendar to implement Date + 1 day sDate = c. getTime (); System. out. println ("Date end Date + 1" + f. format (sDate); // print the Date. The value is displayed successfully + 1 day SimpleDateFormat sdf1 = new SimpleDateFormat ("yyyy-MM-dd"); endDate = sdf1.format (sDate ); system. out. println ("Convert Date type to String type" + endDate); // convert the Date type to String type to facilitate database comparison
String type 2011-1-23string type to Date type Tue Jan 23 00:00:00 CST 2018Date end Date: 2011-1-23date end Date + 1 2011-1-24date type to String type 2011-1-24