import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Locale;

public class Main {
	public static void main(String[] args) {
		String strStartDateTime = "2021-01-01 00:00:00";
		String strEndDateTime = "2021-01-01 10:00:00";

		DateTimeFormatter dtf = DateTimeFormatter.ofPattern("uuuu-MM-dd HH:mm:ss", Locale.ENGLISH);

		LocalDateTime ldtStart = LocalDateTime.parse(strStartDateTime, dtf);
		LocalDateTime ldtEnd = LocalDateTime.parse(strEndDateTime, dtf);

		for (LocalDateTime ldt = ldtStart; !ldt.isAfter(ldtEnd); ldt = ldt.plusHours(1)) {
			// System.out.println(ldt);

			// Formatted
			System.out.println(ldt.format(dtf));

			// ...Your logic
		}
	}
}