Given a date, how do I get the day after this date? This is not a simple current date plus one thing. On the last day of the year, the last day of the month will be transferred to the next one months, which will make a mistake. Here is a simple way to use the method provided by the Calendar class. Words are not more directly on the code.
public static string Getthenextdate (String date) {//201711191600 if (date!=null&&date.lengt
H () >=8) {date=date.substring (0, 8);
}else {return "";
} String year=date.substring (0,4);
String month=date.substring (4,6);
String day1=date.substring (6,8);
System.out.println (year+ "" +month+ "" +day1);
String datestr=year+ "-" +month+ "-" +day1;
Date Mydate=null;
Calendar calendar=calendar.getinstance ();
try {mydate=new SimpleDateFormat ("Yyyy-mm-dd"). Parse (DATESTR);
catch (ParseException e) {e.printstacktrace ();
} calendar.settime (MyDate);
int Day=calendar.get (calendar.date);
Calendar.set (Calendar.date, day+1);
String dayafter=new SimpleDateFormat ("Yyyy-mm-dd"). Format (Calendar.gettime ());
System.out.println (Dayafter);
String [] Datearray=dayafter.split ("-");
String dayafter1= "";
for (int i = 0; i < datearray.length i++) {dayafter1+=datearray[i];
return dayAfter1; }
The landlord test, copy can be used.