Java Date Compare by Day sameDay(Date t1, Date t2)

Here you can find the source of sameDay(Date t1, Date t2)

Description

same Day

License

Open Source License

Declaration

public static boolean sameDay(Date t1, Date t2) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * Copyright (c) 2013 Dominik Halfkann, Michael Backhaus, Benjamin Kramer,
 * Fabian K?nig, Karl Stelzner, Stefan Noll and Alexander Schieweck.
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU Public License v3.0
 * which accompanies this distribution, and is available at
 * http://www.gnu.org/licenses/gpl.html/*from  w  w w.  ja  v  a  2s.  co m*/
 ******************************************************************************/

import java.util.Calendar;
import java.util.Date;

public class Main {
    private static Calendar c1 = Calendar.getInstance();
    private static Calendar c2 = Calendar.getInstance();

    public static boolean sameDay(Date t1, Date t2) {
        c1.setTime(t1);
        c2.setTime(t2);
        return (c1.get(Calendar.YEAR) == c2.get(Calendar.YEAR))
                && (c1.get(Calendar.MONTH) == c2.get(Calendar.MONTH))
                && (c1.get(Calendar.DAY_OF_MONTH) == c2.get(Calendar.DAY_OF_MONTH));
    }
}

Related

  1. sameDay(Date date1, Date date2)
  2. sameDay(Date date1, Date date2)
  3. sameDay(Date date1, Date date2)
  4. sameDay(Date date1, Date date2)
  5. sameDay(Date dateOne, Date dateTwo)
  6. sameDay(Date t1, Date t2, TimeZone tz)
  7. sameDay(int firstDate, int secondDate)