Here you can find the source of sameDay(Date t1, Date t2, TimeZone tz)
Parameter | Description |
---|---|
t1 | a parameter |
t2 | a parameter |
tz | a parameter |
public static boolean sameDay(Date t1, Date t2, TimeZone tz)
//package com.java2s; /*/*from w ww . j av a2 s .c o m*/ * ***** BEGIN LICENSE BLOCK ***** * Zimbra Collaboration Suite Server * Copyright (C) 2006, 2007, 2009, 2010, 2013, 2014, 2016 Synacor, Inc. * * This program is free software: you can redistribute it and/or modify it under * the terms of the GNU General Public License as published by the Free Software Foundation, * version 2 of the License. * * This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; * without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. * See the GNU General Public License for more details. * You should have received a copy of the GNU General Public License along with this program. * If not, see <https://www.gnu.org/licenses/>. * ***** END LICENSE BLOCK ***** */ import java.util.Calendar; import java.util.Date; import java.util.GregorianCalendar; import java.util.TimeZone; public class Main { /** * Determines if the two dates are in the same day in the given time zone. * @param t1 * @param t2 * @param tz * @return */ public static boolean sameDay(Date t1, Date t2, TimeZone tz) { Calendar cal1 = new GregorianCalendar(tz); cal1.setTime(t1); Calendar cal2 = new GregorianCalendar(tz); cal2.setTime(t2); return cal1.get(Calendar.YEAR) == cal2.get(Calendar.YEAR) && cal1.get(Calendar.MONTH) == cal2.get(Calendar.MONTH) && cal1.get(Calendar.DAY_OF_MONTH) == cal2.get(Calendar.DAY_OF_MONTH); } }