import java.io.PrintStream;
import java.text.*;
import java.util.*;

public class DateDiff
{

    protected int getDateDiff(int i, Date date, Date date1)
    {
        boolean flag = false;
        if(date.after(date1))
        {
            Date date2 = date;
            date = date1;
            date1 = date2;
            flag = true;
        }
        int j = getEstDiff(i, date, date1);
        GregorianCalendar gregoriancalendar = new GregorianCalendar();
        gregoriancalendar.setTime(date);
        GregorianCalendar gregoriancalendar1 = new GregorianCalendar();
        gregoriancalendar1.setTime(date1);
        gregoriancalendar.add(i, j - 2);
        int k = j - 1;
        do
        {
            gregoriancalendar.add(i, 1);
            if(gregoriancalendar.after(gregoriancalendar1))
                if(flag)
                    return 1 - k;
                else
                    return k - 1;
            k++;
        } while(true);
    }

    private int getEstDiff(int i, Date date, Date date1)
    {
        long l = date1.getTime() - date.getTime();
        switch(i)
        {
        case 5: // '\005'
        case 8: // '\b'
            return (int)((double)l / 86405400D + 0.5D);

        case 3: // '\003'
            return (int)((double)l / 604837800D + 0.5D);

        case 2: // '\002'
            return (int)((double)l / 2629899558.4499998D + 0.5D);

        case 1: // '\001'
            return (int)((double)l / 31572533160D + 0.5D);
        }
        return 0;
    }

    public static void main(String args[])
    {
        DateDiff datediff = new DateDiff();
        Date date = null;
        Date date1 = null;
        DateFormat dateformat = DateFormat.getInstance();
        PaddedDecimalFormat paddeddecimalformat = PaddedDecimalFormat.getNumberInstance(0, Locale.getDefault());
        dateformat.setTimeZone(TimeZone.getDefault());
        if(args.length < 2)
        {
            String s = ((SimpleDateFormat)dateformat).toLocalizedPattern();
            System.out.println("Usage: Enter two dates in this format: " + s.substring(0, s.indexOf(32)));
            System.exit(0);
        } else
        {
            try
            {
                date = dateformat.parse(args[0] + " 12:00 PM");
                date1 = dateformat.parse(args[1] + " 12:00 PM");
            }
            catch(ParseException parseexception)
            {
                System.out.println("Couldn't parse date: " + parseexception);
                System.exit(1);
            }
        }
        int i = datediff.getDateDiff(5, date, date1);
        System.out.println("Interval in days:   " + paddeddecimalformat.format(i, 20));
        i = datediff.getDateDiff(3, date, date1);
        System.out.println("Interval in weeks:  " + paddeddecimalformat.format(i, 20));
        i = datediff.getDateDiff(2, date, date1);
        System.out.println("Interval in months: " + paddeddecimalformat.format(i, 20));
        i = datediff.getDateDiff(1, date, date1);
        System.out.println("Interval in years:  " + paddeddecimalformat.format(i, 20));
    }

    public DateDiff()
    {
    }

    private static final double DAY_MILLIS = 86405400D;
    private static final double WEEK_MILLIS = 604837800D;
    private static final double MONTH_MILLIS = 2629899558.4499998D;
    private static final double YEAR_MILLIS = 31572533160D;
}
