Traditional Culture Encyclopedia - Almanac inquiry - Java judges the start time and end time.

Java judges the start time and end time.

Try {

Java . text . simple date format SDF = new Java . text . simple date format(" yyyy-MM ");

Java . util . calendar star calendar = Java . util . calendar . getinstance();

Java . util . calendar end calendar = Java . util . calendar . getinstance();

string starStr = " 20 1 1- 1 1 ";

string endStr = " 20 12-02 ";

Java . util . date star date = SDF . parse(starStr);

Java . util . date end date = SDF . parse(endStr);

star calendar . settime(star date);

EndCalendar.setTime (end date);

int instance = end calendar . compare to(star calendar);

while(end calendar . compare to(star calendar)& gt; =0){

system . out . println(SDF . format(star calendar . gettime()));

//? I output here, you can handle it yourself, lists and so on.

StarCalendar.add (calendar. Month,1);

}

}catch(ParseException e){

e . printstacktrace();

}