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

import java.util.*;
import java.lang.*;
import java.io.*;
import java.text.SimpleDateFormat;


/* Name of the class has to be "Main" only if the class is public. */
public class Main {

    public static void main(String[] args) throws Exception {
        Booking[] bookings = {
                new Booking(new SimpleDateFormat("yyyy-M-d", Locale.ENGLISH).parse("2016-10-12"),new SimpleDateFormat("yyyy-M-d", Locale.ENGLISH).parse("2016-10-18") ),
                new Booking(new SimpleDateFormat("yyyy-M-d", Locale.ENGLISH).parse("2016-10-11"),new SimpleDateFormat("yyyy-M-d", Locale.ENGLISH).parse("2016-10-15") ),
                new Booking(new SimpleDateFormat("yyyy-M-d", Locale.ENGLISH).parse("2016-10-13"),new SimpleDateFormat("yyyy-M-d", Locale.ENGLISH).parse("2016-10-14") ),
                new Booking(new SimpleDateFormat("yyyy-M-d", Locale.ENGLISH).parse("2016-10-12"),new SimpleDateFormat("yyyy-M-d", Locale.ENGLISH).parse("2016-10-13") ),
        };

        System.out.println(getDaysBetweenDates(bookings));

    }

    public static Date getMaxOccurence(Booking[] booking) {
        List<Date> dates = new ArrayList<Date>();
        Date max = new Date();
        int freq = 0;
        for (Booking b : booking) {
            Calendar calendar = new GregorianCalendar();
            calendar.setTime(b.getStartDate());

            while (calendar.getTime().before(b.getEndDate())) {
                Date result = calendar.getTime();
                dates.add(result);
                int curr = Collections.frequency(dates, result);
                if (curr > freq) {
                    freq = curr;
                    max = result;
                }
                calendar.add(Calendar.DATE, 1);
            }
        }
        return max;
    }

    static class Booking {
        Date startDate;
        Date endDate;

        public Booking(Date startDate, Date endDate) {
            this.startDate = startDate;
            this.endDate = endDate;
        }

        public Date getStartDate() {
            return startDate;
        }

        public void setStartDate(Date startDate) {
            this.startDate = startDate;
        }

        public Date getEndDate() {
            return endDate;
        }

        public void setEndDate(Date endDate) {
            this.endDate = endDate;
        }
    }
}