List of usage examples for java.util Date after
public boolean after(Date when)
From source file:de.micromata.genome.util.types.DateUtils.java
/** * If one of the date is null, it returns the other. * * @param left the left//from ww w . ja v a 2 s . c om * @param right the right * @return later of both dates. */ public static Date max(final Date left, final Date right) { if (left == null) { return right; } if (right == null) { return left; } if (left.after(right) == true) { return left; } else { return right; } }
From source file:com.plugin.am.LocalNotification.java
/** * Retrieves a list with all currently triggered notifications. * * @param callbackContext/*from w w w. java 2 s . c o m*/ */ public static void getTriggeredIds(CallbackContext command) { SharedPreferences settings = getSharedPreferences(); Map<String, ?> alarms = settings.getAll(); Set<String> alarmIds = alarms.keySet(); JSONArray scheduledIds = new JSONArray(); Date now = new Date(); for (String id : alarmIds) { JSONObject arguments = (JSONObject) alarms.get(id); Options options = new Options(context).parse(arguments); Date fireDate = new Date(options.getDate()); boolean isTriggered = now.after(fireDate); if (isTriggered == true) { scheduledIds.put(id); } } command.success(scheduledIds); }
From source file:com.sccl.attech.common.utils.DateUtils.java
/** * ??//w ww . ja v a 2 s . com * @param startTime * @param endTime * @return * @throws ParseException */ public static Boolean isBetweenTime(Date startTime, Date endTime) { SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd"); String current = formatter.format(new Date()); //? Date start; Date end; Date currentTime; try { start = formatter.parse(formatter.format(startTime)); end = formatter.parse(formatter.format(endTime)); currentTime = formatter.parse(current); return ((currentTime.before(end) && currentTime.after(start)) || currentTime.equals(start) || currentTime.equals(end)); } catch (ParseException e) { e.printStackTrace(); } return false; }
From source file:net.kamhon.ieagle.util.DateUtil.java
/** * Not Consider time. Just compare date. * //www . j a v a2s . c o m * @param date * @param startDate * @param endDate * @return */ public static boolean isBetweenDate(Date date, Date startDate, Date endDate) { Date clonedDate = (Date) date.clone(); clonedDate = formatDateByTime(clonedDate, 0, 0, 0, 0); Date clonedStartDate = (Date) startDate.clone(); Date clonedEndDate = (Date) endDate.clone(); clonedStartDate = formatDateByTime(clonedStartDate, 0, 0, 0, 0); clonedEndDate = formatDateByTime(clonedEndDate, 23, 59, 59, 999); return (clonedDate.equals(clonedStartDate) || clonedDate.after(clonedStartDate)) && (clonedDate.equals(clonedEndDate) || clonedDate.before(clonedEndDate)); }
From source file:jp.co.ctc_g.jse.core.validation.util.Validators.java
/** * ????????//from w w w. ja v a 2s. c o m * @param suspect * @param target ? * @return ?????false */ public static boolean after(Date suspect, Date target) { if (suspect == null) return true; return suspect.after(target); }
From source file:jp.co.ctc_g.jse.core.validation.util.Validators.java
/** * ??????????????/*from w w w . j ava 2 s. c o m*/ * @param suspect * @param target ? * @return ?????????false */ public static boolean afterEqualsTo(Date suspect, Date target) { if (suspect == null) return true; return suspect.after(target) || suspect.equals(target); }
From source file:com.aurel.track.fieldType.runtime.system.text.SystemDateRT.java
/** * Get the earliest start date or the latest endDate of all children * @param parentID/*w ww. ja va 2 s . com*/ * @param earliest * @return */ private static Date getOutermostChildDate(Integer parentID, Integer fieldID, boolean earliest) { Date date = null; List<TWorkItemBean> siblingWorkItemBeans = ItemBL.getChildren(parentID); if (siblingWorkItemBeans != null && !siblingWorkItemBeans.isEmpty()) { for (TWorkItemBean siblingWorkItemBean : siblingWorkItemBeans) { Date siblingDate = (Date) siblingWorkItemBean.getAttribute(fieldID); if (siblingDate != null && (date == null || (earliest && siblingDate.before(date)) || (!earliest && siblingDate.after(date)))) { date = siblingDate; } } } return date; }
From source file:DateUtil.java
/** * Returns true if endDate is after startDate or if startDate equals endDate. * Returns false if either value is null. If equalOK, returns true if the * dates are equal.// w w w.j a v a 2 s. c o m **/ public static boolean isValidDateRange(Date startDate, Date endDate, boolean equalOK) { // false if either value is null if (startDate == null || endDate == null) { return false; } if (equalOK) { // true if they are equal if (startDate.equals(endDate)) { return true; } } // true if endDate after startDate if (endDate.after(startDate)) { return true; } return false; }
From source file:edu.stanford.muse.email.CalendarUtil.java
/** intervals must be sorted, start from before the earliest date, and end after the latest date */ public static int[] computeHistogram(List<Date> dates, List<Date> intervals, boolean ignoreInvalidDates) { if (intervals == null || intervals.size() == 0) return new int[0]; int nIntervals = intervals.size() - 1; int[] counts = new int[nIntervals]; if (ignoreInvalidDates) { int count = 0; List<Date> newDates = new ArrayList<Date>(); for (Date d : dates) if (!EmailFetcherThread.INVALID_DATE.equals(d)) newDates.add(d);//from w w w. j a v a 2 s .com else count++; dates = newDates; if (count > 0) log.info(count + " invalid date(s) ignored"); } if (dates.size() == 0) return counts; Collections.sort(dates); Date firstDate = dates.get(0); Date lastDate = dates.get(dates.size() - 1); // intervals are assumed to be already sorted if (firstDate.before(intervals.get(0))) throw new RuntimeException("INTERNAL ERROR: invalid dates, first date " + formatDateForDisplay(firstDate) + " before intervals start " + formatDateForDisplay(intervals.get(0)) + ", aborting histogram computation"); if (lastDate.after(intervals.get(intervals.size() - 1))) throw new RuntimeException("INTERNAL ERROR: invalid dates, last date " + formatDateForDisplay(firstDate) + " after intervals end " + formatDateForDisplay(intervals.get(intervals.size() - 1)) + ", aborting histogram computation"); int currentInterval = 0; int thisIntervalCount = 0; // running count which we are accumulating into the current interval // no need to track currentIntervalStart explicitly Date currentIntervalEnd = intervals.get(currentInterval + 1); // we'll run down the sorted dates, counting dates in each interval for (Date currentDate : dates) { if (currentDate.after(currentIntervalEnd)) { // we're done with current interval, commit its count counts[currentInterval] = thisIntervalCount; // find the next interval, skip over till current Date is before the interval end do { currentInterval++; currentIntervalEnd = intervals.get(currentInterval + 1); } while (currentDate.after(currentIntervalEnd)); // now current date is before the current interval end, so we have the new interval reflected in currentIntervalEnd // count currentDate in this interval thisIntervalCount = 1; } else thisIntervalCount++; // still not reached end of interval } // the last interval's end was not exceeded, so set up its count here counts[currentInterval] = thisIntervalCount; return counts; }
From source file:Dates.java
/** * Difference of 2 dates in years, months and days. <p> * /*from w w w. ja v a2 s . c om*/ * @param f1 If null returns null * @param f2 If null returns null */ public static DateDistance dateDistance(java.util.Date f1, java.util.Date f2, boolean includeStartDate) { DateDistance df = new DateDistance(); if (null == f1 || null == f2) return null; Calendar fmax = Calendar.getInstance(), fmin = Calendar.getInstance(); f1 = Dates.removeTime(f1); f2 = Dates.removeTime(f2); if (f1.after(f2)) { fmax.setTime(f1); fmin.setTime(f2); } else { fmin.setTime(f1); fmax.setTime(f2); } int initDay = fmin.get(Calendar.DATE); int initMonth = fmin.get(Calendar.MONTH); int initYear = fmin.get(Calendar.YEAR); int endMonth = fmax.get(Calendar.MONTH); int endYear = fmax.get(Calendar.YEAR); int finalLimit = fmax.getActualMaximum(Calendar.DATE); int initPeak = 0; int finalPeak = 0; if (initMonth == endMonth && initYear == endYear) { while (fmin.getTime().before(fmax.getTime())) { fmin.add(Calendar.DATE, 1); df.days++; } if (includeStartDate) { df.days++; } if (df.days >= finalLimit) { df.months++; df.days = 0; } return df; } if (initDay != 1) { while (fmin.get(Calendar.DATE) != 1) { fmin.add(Calendar.DATE, 1); initPeak++; } } while (fmin.get(Calendar.MONTH) != endMonth || fmin.get(Calendar.YEAR) != endYear) { fmin.add(Calendar.MONTH, 1); df.months++; if (df.months == 12) { df.years++; df.months = 0; } } while (fmin.getTime().before(fmax.getTime())) { fmin.add(Calendar.DATE, 1); finalPeak++; } int peak = initPeak + finalPeak; if (includeStartDate) { peak++; } if (peak >= finalLimit) { peak = peak - finalLimit; df.months++; if (df.months == 12) { df.years++; df.months = 0; } } df.days = peak; return df; }