/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.BigDecimal;
import java.time.Instant;
import java.time.LocalDate;
import java.time.Year;
import java.time.YearMonth;
import java.time.ZoneOffset;
import java.time.format.DateTimeParseException;
import java.time.format.DateTimeFormatter;


/* Name of the class has to be "Main" only if the class is public. */
class Ideone
{
	public static void main(String[] args) {
        String[] strs = {"2018", "2010", "2009",
                "2018-03", "2010-02", "2010-03",
                "2012-01-05", "2020-03-01", "2020-04-01"};

        Instant start = Instant.parse("2010-05-01T00:00:00Z");
        Instant end = Instant.parse("2020-03-01T23:59:59.999999999Z");

        for (String str : strs) {
            System.out.println(isValid(str, start, end));
        }
    }

    public static boolean isValid(String date, Instant start, Instant end) {
	    LocalDate sld = start.atOffset(ZoneOffset.UTC).toLocalDate();
	    LocalDate eld = end.atOffset(ZoneOffset.UTC).toLocalDate();
	    try {
	        LocalDate ld = LocalDate.parse(date);
	        return ld.isAfter(sld) && ld.isBefore(eld);
	    } catch (DateTimeParseException e) {}
	
	    try {
	        YearMonth ym = YearMonth.parse(date);
	        return ym.isAfter(YearMonth.from(sld)) && ym.isBefore(YearMonth.from(eld));
	    } catch (DateTimeParseException e) {}
	
	    try {
	        Year y = Year.parse(date);
	        return y.isAfter(Year.from(sld)) && y.isBefore(Year.from(eld));
	    } catch (DateTimeParseException e) {
	    }
	    return false;
	}
}