Here you can find the source of equals(Calendar calendar1, Calendar calendar2)
Parameter | Description |
---|---|
calendar1 | a parameter |
calendar2 | a parameter |
public static boolean equals(Calendar calendar1, Calendar calendar2)
//package com.java2s; /*/*w ww.j av a2 s. c o m*/ * Copyright (C) 2009-2015 SM2 SOFTWARE & SERVICES MANAGEMENT * 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, either version 3 of the License, or * (at your option) any later version. * * This program has been created in the hope that it will be useful. * It is distributed WITHOUT ANY WARRANTY of any Kind, * 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 http://www.gnu.org/licenses/. * * For more information, please contact SM2 Software & Services Management. * Mail: info@talaia-openppm.com * Web: http://www.talaia-openppm.com * * Module: utils * File: DateUtil.java * Create User: javier.hernandez * Create Date: 06/03/2015 14:35:37 */ import java.util.*; public class Main { public static Locale DEF_LOCALE = new Locale("en", "US"); /** * Equals two dates, compare day to day, month to month and year to year * @param calendar1 * @param calendar2 * @return */ public static boolean equals(Date date1, Date date2) { Calendar calendar1 = getCalendar(); calendar1.setTime(date1); Calendar calendar2 = getCalendar(); calendar2.setTime(date2); return equals(calendar1, calendar2); } /** * Equals two calendar, compare day to day, month to month and year to year * @param calendar1 * @param calendar2 * @return */ public static boolean equals(Calendar calendar1, Calendar calendar2) { int day1 = calendar1.get(Calendar.DAY_OF_MONTH); int day2 = calendar2.get(Calendar.DAY_OF_MONTH); int month1 = calendar1.get(Calendar.MONTH); int month2 = calendar2.get(Calendar.MONTH); int year1 = calendar1.get(Calendar.YEAR); int year2 = calendar2.get(Calendar.YEAR); return (day1 == day2 && month1 == month2 && year1 == year2); } /** * Get Default Locale Calendar (default: Locale("en", "US")) * @return */ public static Calendar getCalendar() { return getCalendar(DEF_LOCALE); } /** * Get Default Locale Calendar * @param locale * @return */ public static Calendar getCalendar(Locale locale) { Calendar cal = Calendar.getInstance(locale); cal.setFirstDayOfWeek(Calendar.MONDAY); return cal; } }