/** * <p>Checks if two date objects are on the same day ignoring time.</p> * * <p>28 Mar 2002 13:45 and 28 Mar 2002 06:01 would return true. * 28 Mar 2002 13:45 and 12 Mar 2002 13:45 would return false. * </p> * * @param date1 the first date, not altered, not null * @param date2 the second date, not altered, not null * @return true if they represent the same day * @throws IllegalArgumentException if either date is <code>null</code> * @since 2.1 */ public static boolean isSameDay(Date date1, Date date2) { if (date1 == null || date2 == null) { throw new IllegalArgumentException("The date must not be null"); } Calendar cal1 = Calendar.getInstance(); cal1.setTime(date1); Calendar cal2 = Calendar.getInstance(); cal2.setTime(date2); return isSameDay(cal1, cal2); }
static List<Interval> group(List<PurgeableAnalysisDto> snapshots, Date start, Date end, int calendarField) { List<Interval> intervals = Lists.newArrayList(); GregorianCalendar calendar = new GregorianCalendar(); int lastYear = -1; int lastFieldValue = -1; Interval currentInterval = null; for (PurgeableAnalysisDto snapshot : snapshots) { if (!DateUtils.isSameDay(start, snapshot.getDate()) && snapshot.getDate().after(start) && (snapshot.getDate().before(end) || DateUtils.isSameDay(end, snapshot.getDate()))) { calendar.setTime(snapshot.getDate()); int currentFieldValue = calendar.get(calendarField); int currentYear = calendar.get(Calendar.YEAR); if (lastYear != currentYear || lastFieldValue != currentFieldValue) { currentInterval = new Interval(); intervals.add(currentInterval); } lastFieldValue = currentFieldValue; lastYear = currentYear; if (currentInterval != null) { currentInterval.add(snapshot); } } } return intervals; } }
private void writeToLog(String name) throws IOException { if (logWriter == null) return; // Increment the date if we have to Date now = new Date(); if (!DateUtils.isSameDay(today, now)) { today = now; startNewLog(); } logWriter.append(logFormatter.format(now)).append(" Metric: ").append(name).append(": ") .append(registry.get(name).toString()).append("\n"); }
/** * return true if the date 1 and date 2 is on the same day * * @param d1 * @param d2 * @return */ public static boolean isSameDay(Date d1, Date d2) { if (d1 == null && d2 == null) return true; if (d1 == null || d2 == null) return false; return org.apache.commons.lang.time.DateUtils.isSameDay(d1, d2); }
/** * Determines if the current date is the same as the last day of the fiscal year * * @return */ protected boolean isLastDayOfFiscalYear(){ Date lastDateOfFiscalYear = (Date) kemService.getFiscalYearEndDayAndMonth(); return DateUtils.isSameDay( currentDate, lastDateOfFiscalYear ); }
private void writeToLog(String name) throws IOException { if (null == logWriter) return; // Increment the date if we have to Date now = new Date(); if (!DateUtils.isSameDay(today, now)) { today = now; startNewLog(); } logWriter.append(logFormatter.format(now)).append(" Metric: ").append(name).append(": ").append(registry.get(name).toString()).append("\n"); }
private void writeToLog(String name) throws IOException { if (null == logWriter) return; // Increment the date if we have to Date now = new Date(); if (!DateUtils.isSameDay(today, now)) { today = now; startNewLog(); } logWriter.append(logFormatter.format(now)).append(" Metric: ").append(name).append(": ") .append(registry.get(name).toString()).append("\n"); }
/** * <p>Checks if two date objects are on the same day ignoring time.</p> * * <p>28 Mar 2002 13:45 and 28 Mar 2002 06:01 would return true. * 28 Mar 2002 13:45 and 12 Mar 2002 13:45 would return false. * </p> * * @param date1 the first date, not altered, not null * @param date2 the second date, not altered, not null * @return true if they represent the same day * @throws IllegalArgumentException if either date is <code>null</code> * @since 2.1 */ public static boolean isSameDay(Date date1, Date date2) { if (date1 == null || date2 == null) { throw new IllegalArgumentException("The date must not be null"); } Calendar cal1 = Calendar.getInstance(); cal1.setTime(date1); Calendar cal2 = Calendar.getInstance(); cal2.setTime(date2); return isSameDay(cal1, cal2); }
/** * <p>Checks if two date objects are on the same day ignoring time.</p> * * <p>28 Mar 2002 13:45 and 28 Mar 2002 06:01 would return true. * 28 Mar 2002 13:45 and 12 Mar 2002 13:45 would return false. * </p> * * @param date1 the first date, not altered, not null * @param date2 the second date, not altered, not null * @return true if they represent the same day * @throws IllegalArgumentException if either date is <code>null</code> * @since 2.1 */ public static boolean isSameDay(Date date1, Date date2) { if (date1 == null || date2 == null) { throw new IllegalArgumentException("The date must not be null"); } Calendar cal1 = Calendar.getInstance(); cal1.setTime(date1); Calendar cal2 = Calendar.getInstance(); cal2.setTime(date2); return isSameDay(cal1, cal2); }
/** * <p>Checks if two date objects are on the same day ignoring time.</p> * * <p>28 Mar 2002 13:45 and 28 Mar 2002 06:01 would return true. * 28 Mar 2002 13:45 and 12 Mar 2002 13:45 would return false. * </p> * * @param date1 the first date, not altered, not null * @param date2 the second date, not altered, not null * @return true if they represent the same day * @throws IllegalArgumentException if either date is <code>null</code> * @since 2.1 */ public static boolean isSameDay(Date date1, Date date2) { if (date1 == null || date2 == null) { throw new IllegalArgumentException("The date must not be null"); } Calendar cal1 = Calendar.getInstance(); cal1.setTime(date1); Calendar cal2 = Calendar.getInstance(); cal2.setTime(date2); return isSameDay(cal1, cal2); }
/** * <p>Checks if two date objects are on the same day ignoring time.</p> * * <p>28 Mar 2002 13:45 and 28 Mar 2002 06:01 would return true. * 28 Mar 2002 13:45 and 12 Mar 2002 13:45 would return false. * </p> * * @param date1 the first date, not altered, not null * @param date2 the second date, not altered, not null * @return true if they represent the same day * @throws IllegalArgumentException if either date is <code>null</code> * @since 2.1 */ public static boolean isSameDay(Date date1, Date date2) { if (date1 == null || date2 == null) { throw new IllegalArgumentException("The date must not be null"); } Calendar cal1 = Calendar.getInstance(); cal1.setTime(date1); Calendar cal2 = Calendar.getInstance(); cal2.setTime(date2); return isSameDay(cal1, cal2); }
/** * <p>Checks if two date objects are on the same day ignoring time.</p> * * <p>28 Mar 2002 13:45 and 28 Mar 2002 06:01 would return true. * 28 Mar 2002 13:45 and 12 Mar 2002 13:45 would return false. * </p> * * @param date1 the first date, not altered, not null * @param date2 the second date, not altered, not null * @return true if they represent the same day * @throws IllegalArgumentException if either date is <code>null</code> * @since 2.1 */ public static boolean isSameDay(Date date1, Date date2) { if (date1 == null || date2 == null) { throw new IllegalArgumentException("The date must not be null"); } Calendar cal1 = Calendar.getInstance(); cal1.setTime(date1); Calendar cal2 = Calendar.getInstance(); cal2.setTime(date2); return isSameDay(cal1, cal2); }
/** * Determines if the current date is the same as the first day of the fiscal year * * @param currentDate * @return */ protected boolean isFirstDayOfFiscalYear(){ Date firstDateOfFiscalYear = (Date) universityDateService.getFirstDateOfFiscalYear( universityDateService.getCurrentFiscalYear() ); return DateUtils.isSameDay( currentDate, firstDateOfFiscalYear ); }
static List<Interval> group(List<PurgeableAnalysisDto> snapshots, Date start, Date end, int calendarField) { List<Interval> intervals = Lists.newArrayList(); GregorianCalendar calendar = new GregorianCalendar(); int lastYear = -1; int lastFieldValue = -1; Interval currentInterval = null; for (PurgeableAnalysisDto snapshot : snapshots) { if (!DateUtils.isSameDay(start, snapshot.getDate()) && snapshot.getDate().after(start) && (snapshot.getDate().before(end) || DateUtils.isSameDay(end, snapshot.getDate()))) { calendar.setTime(snapshot.getDate()); int currentFieldValue = calendar.get(calendarField); int currentYear = calendar.get(Calendar.YEAR); if (lastYear != currentYear || lastFieldValue != currentFieldValue) { currentInterval = new Interval(); intervals.add(currentInterval); } lastFieldValue = currentFieldValue; lastYear = currentYear; if (currentInterval != null) { currentInterval.add(snapshot); } } } return intervals; } }
Date lastDateFromLog = dateFormat.parse(date); if (!DateUtils.isSameDay(today, lastDateFromLog)) {
/** * 比较两个日期的先后 * @param date1 日期1 "yyyy-MM-dd" * @param date2 日期2 "yyyy-MM-dd" * @param mask 格式"yyyy-MM-dd" "yyyy/MM/dd" * @return '1' 日期1>日期2<br> '-1' 日期2>日期1<br> '0' 日期1=日期2 * @throws ParseException */ public static int compareDate(String date1, String date2, String mask) throws ParseException { Date d1 = convertStringToDate(mask, date1); Date d2 = convertStringToDate(mask, date2); if(DateUtils.isSameDay(d1, d2)){ return 0; } return compareDate(d1, d2); }
DateTime currentBeginDate = calendarEntry.getBeginPeriodFullDateTime(); if (currentBeginDate.isBefore(asOfDate) || DateUtils.isSameDay(currentBeginDate.toDate(), asOfDate.toDate())) { CalendarEntry previousCalendarEntry = getCalendarEntryService().getPreviousCalendarEntryByCalendarId(hrCalendarId, calendarEntry);
/** * @see org.kuali.kfs.fp.businessobject.Check#isLike(org.kuali.kfs.fp.businessobject.Check) */ public boolean isLike(Check other) { boolean like = false; if (StringUtils.equals(checkNumber, other.getCheckNumber())) { if (StringUtils.equals(description, other.getDescription())) { if (StringUtils.equals(financialDocumentTypeCode, other.getFinancialDocumentTypeCode()) && StringUtils.equals(cashieringRecordSource, other.getCashieringRecordSource())) { if (StringUtils.equals(documentNumber, other.getDocumentNumber())) { if (NumberUtils.equals(sequenceId, other.getSequenceId())) { if (NumberUtils.equals(financialDocumentDepositLineNumber, other.getFinancialDocumentDepositLineNumber())) { if (DateUtils.isSameDay(checkDate, other.getCheckDate())) { if ((amount != null) && amount.equals(other.getAmount())) { like = true; } } } } } } } } return like; } }
TimesheetDocumentHeader tdh = TkServiceLocator.getTimesheetDocumentHeaderService().getDocumentHeaderForDate(principalId, leaveBlockDate); if (tdh != null) { if (DateUtils.isSameDay(leaveBlockDate.toDate(), tdh.getEndDate()) || leaveBlockDate.isAfter(tdh.getEndDateTime())) { requestStatus = HrConstants.REQUEST_STATUS.PLANNED; if (DateUtils.isSameDay(leaveBlockDate.toDate(), calendarEntry.getEndPeriodFullDateTime().toDate()) || leaveBlockDate.isAfter(calendarEntry.getEndPeriodFullDateTime())) { requestStatus = HrConstants.REQUEST_STATUS.PLANNED;