Java Calendar Day isSameDay(final Calendar date1, final Calendar date2)

Here you can find the source of isSameDay(final Calendar date1, final Calendar date2)

Description

is Same Day

License

Open Source License

Declaration

private static boolean isSameDay(final Calendar date1,
            final Calendar date2) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2009 Lifeform Software.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * Contributors:/*w w  w  .  j  a v a  2  s. c om*/
 *     Ernan Hughes - initial API and implementation
 *******************************************************************************/

import java.util.Calendar;

public class Main {
    private static final int miliPerDay = 60 * 60 * 24 * 1000;

    private static boolean isSameDay(final Calendar date1,
            final Calendar date2) {
        return getDaysBetween(date1, date2) < miliPerDay;
    }

    public static double getDaysBetween(final Calendar start,
            final Calendar end) {
        return getDaysBetween(start.getTimeInMillis(),
                end.getTimeInMillis());
    }

    public static double getDaysBetween(final long start, final long end) {
        int days = (int) ((end - start) / miliPerDay);
        return days;
    }
}

Related

  1. isSameDay(Calendar cal1, Calendar cal2)
  2. isSameDay(Calendar day1, Calendar day2)
  3. isSameDay(Calendar dayOne, Calendar dayTwo)
  4. isSameDay(Calendar today, Date now)
  5. isSameDay(final Calendar cal1, final Calendar cal2)
  6. isSunday(GregorianCalendar date)
  7. isTheSameDay(Calendar dayOne, Calendar dayTwo)
  8. isToday(Calendar creationDate)
  9. isToday(Calendar date)