Here you can find the source of isEqualYMD(Date begindate, Date enddate)
Parameter | Description |
---|---|
begindate | begin date |
enddate | end date |
public static boolean isEqualYMD(Date begindate, Date enddate)
//package com.java2s; /*/*from ww w .jav a2s .c o m*/ * File: $RCSfile$ * * Copyright (c) 2005 Wincor Nixdorf International GmbH, * Heinz-Nixdorf-Ring 1, 33106 Paderborn, Germany * All Rights Reserved. * * This software is the confidential and proprietary information * of Wincor Nixdorf ("Confidential Information"). You shall not * disclose such Confidential Information and shall use it only in * accordance with the terms of the license agreement you entered * into with Wincor Nixdorf. */ import java.util.Date; import java.util.Calendar; public class Main { /** * add by xie compare date only compare year month day * * @param begindate begin date * @param enddate end date * @return begindate > endate as false */ public static boolean isEqualYMD(Date begindate, Date enddate) { boolean isEquals = true; Calendar startCalendar = Calendar.getInstance(); startCalendar.setTime(begindate); Calendar endCalendar = Calendar.getInstance(); endCalendar.setTime(enddate); int startYear = startCalendar.get(Calendar.YEAR); int startMonth = startCalendar.get(Calendar.MONTH); int startDay = startCalendar.get(Calendar.DATE); int endYear = endCalendar.get(Calendar.YEAR); int endMonth = endCalendar.get(Calendar.MONTH); int endDay = endCalendar.get(Calendar.DATE); if (startYear != endYear || startMonth != endMonth || startDay != endDay) { isEquals = false; } return isEquals; } }