code: public void formatDate(int year, int month, int day, boolean extended, Appendable buffer) {
  
      try {
        // year
        String yearString = String.valueOf(year);
        buffer.append(yearString);
        if (extended) {
          buffer.append('-');
        }
        // month
        String monthString = String.valueOf(month);
        if (monthString.length() < 2) {
          buffer.append('0');
        }
        buffer.append(monthString);
        if (extended) {
          buffer.append('-');
        }
        // day
        String dayString = String.valueOf(day);
        if (dayString.length() < 2) {
          buffer.append('0');
        }
        buffer.append(dayString);
      } catch (IOException e) {
        throw new IllegalStateException(e);
      }
    }
docs: @see #formatDate(Date, boolean, Appendable)
  
  @param year is the {@link java.util.Calendar#YEAR year}
  @param month is the month (1-12).
  @param day is the {@link java.util.Calendar#DAY_OF_MONTH day}.
  @param extended if {@code false} the basic date format ("yyyyMMdd") is used, if {@code true} the extended
  date format ("yyyy-MM-dd") is used.
  @param buffer is where to append the formatted date.