List of usage examples for java.util Date equals
public boolean equals(Object obj)
From source file:net.kamhon.ieagle.util.DateUtil.java
/** * consider time and date.// w w w. j ava2 s . c om * * @param date * @param startDate * @param endDate * @return */ public static boolean isBetweenDateTime(Date date, Date startDate, Date endDate) { return (date.equals(startDate) || date.after(startDate)) && (date.equals(endDate) || date.before(endDate)); }
From source file:org.easycloud.las.core.util.TimeUtil.java
public static boolean isBefore(Date time1, Date time2) { assertArgNotNull(time1, "TimeUtil: isBefore time1 null"); assertArgNotNull(time2, "TimeUtil: isBefore time2 null"); return time1.before(time2) || time1.equals(time2); }
From source file:org.apache.falcon.entity.ProcessHelper.java
private static void validateProcessInstance(Process process, Date instanceTime, org.apache.falcon.entity.v0.cluster.Cluster cluster) { //validate the cluster Cluster processCluster = getCluster(process, cluster.getName()); if (processCluster == null) { throw new IllegalArgumentException("Cluster provided: " + cluster.getName() + " is not a valid cluster for the process: " + process.getName()); }/*from ww w . ja v a 2 s . com*/ // check if instanceTime is in validity range if (instanceTime.before(processCluster.getValidity().getStart()) || !instanceTime.before(processCluster.getValidity().getEnd())) { throw new IllegalArgumentException( "Instance time provided: " + instanceTime + " is not in validity range of process: " + process.getName() + "on cluster: " + cluster.getName()); } // check instanceTime is valid on the basis of startTime and frequency Date nextInstance = EntityUtil.getNextStartTime(processCluster.getValidity().getStart(), process.getFrequency(), process.getTimezone(), instanceTime); if (!nextInstance.equals(instanceTime)) { throw new IllegalArgumentException("Instance time provided: " + instanceTime + " for process: " + process.getName() + " is not a valid instance time on cluster: " + cluster.getName() + " on the basis of startDate and frequency"); } }
From source file:nu.mine.kino.projects.utils.WriteUtils.java
private static String getPVHeader(Project project) { StringBuffer buf = new StringBuffer(); buf.append("#" + delimiter); buf.append("^XNID" + delimiter); buf.append("^XN" + delimiter); buf.append("S" + delimiter); Date projectStartDate = project.getProjectStartDate(); Date projectEndDate = project.getProjectEndDate(); // System.out.printf("v?WFNgJn:%s\n", projectStartDate); // System.out.printf("v?WFNg?I:%s\n", projectEndDate); Date targetDate = projectStartDate; while (!targetDate.equals(projectEndDate)) { // System.out.printf("target:%s\n", targetDate); String data = String.format("%s" + delimiter, Utils.date2Str(targetDate, "yyyy/MM/dd")); buf.append(data);// ww w. j a va 2 s .c o m targetDate = DateUtils.addDays(targetDate, 1); } return new String(buf); }
From source file:nu.mine.kino.projects.utils.WriteUtils.java
public static String getPvForPrint(Project project, TaskInformation taskInfo) { StringBuffer buf = new StringBuffer(); Task task = taskInfo.getTask();// www. j av a2 s. co m buf.append(task.getTaskSharp() + delimiter); buf.append(task.getTaskId() + delimiter); buf.append(task.getTaskName() + delimiter); buf.append(task.getPersonInCharge() + delimiter); Date projectStartDate = project.getProjectStartDate(); Date projectEndDate = project.getProjectEndDate(); Date targetDate = projectStartDate; while (!targetDate.equals(projectEndDate)) { double pv = ProjectUtils.calculatePV(task, targetDate); if (!Double.isNaN(pv)) { buf.append(pv); } buf.append(delimiter); targetDate = DateUtils.addDays(targetDate, 1); } return new String(buf); }
From source file:com.redhat.rhn.testing.RhnBaseTestCase.java
/** * Assert that the date <code>later</code> is after the date * <code>earlier</code>. The assertion succeeds if the dates * are equal. Both dates must be non-null. * * @param msg the message to print if the assertion fails * @param earlier the earlier date to compare * @param later the later date to compare *//*w w w . j a v a2 s . c o m*/ public static void assertNotBefore(String msg, Date earlier, Date later) { assertNotNull(msg, earlier); assertNotNull(msg, later); if (earlier.after(later) && !earlier.equals(later)) { String e = DateFormat.getDateTimeInstance().format(earlier); String l = DateFormat.getDateTimeInstance().format(later); throw new ComparisonFailure(msg, e, l); } }
From source file:nu.mine.kino.projects.utils.WriteUtils.java
public static String getPvForPivot(Project project, TaskInformation taskInfo) { StringBuffer buf = new StringBuffer(); Date projectStartDate = project.getProjectStartDate(); Date projectEndDate = project.getProjectEndDate(); Task task = taskInfo.getTask();/*w w w. java 2 s . c om*/ Date targetDate = projectStartDate; while (!targetDate.equals(projectEndDate)) { double pv = ProjectUtils.calculatePV(task, targetDate); if (Utils.isNonZeroNumeric(pv)) { buf.append(task.getTaskSharp() + delimiter); buf.append(task.getTaskId() + delimiter); buf.append(task.getTaskName() + delimiter); buf.append(task.getPersonInCharge() + delimiter); String data = String.format("%s" + delimiter, Utils.date2Str(targetDate, "yyyy/MM/dd")); buf.append(data); buf.append(pv); if (ProjectUtils.isHoliday(project, targetDate)) { buf.append(delimiter + "x"); } buf.append("\n"); } targetDate = DateUtils.addDays(targetDate, 1); } return new String(buf); }
From source file:gov.nasa.arc.spife.ui.table.days.Day.java
public static boolean intersectsExtent(TemporalExtent dayExtent, Date elementStart, Date elementEnd) { Date dayStart = dayExtent.getStart(); if (elementEnd.before(dayStart)) { return false; }//from w w w . ja v a 2s . c o m Date dayEnd = dayExtent.getEnd(); if (elementStart.after(dayEnd)) { return false; } if (elementEnd.equals(dayStart) && !elementStart.equals(dayStart)) { return false; } return true; }
From source file:net.kamhon.ieagle.util.DateUtil.java
/** * Return those date in dates which is between fromDate and toDate. * // www . j av a2s . c om * @return */ public static List<Date> getDateBetween(List<Date> dates, Date fromDate, Date toDate) { List<Date> retDateList = new ArrayList<Date>(); for (Date date : dates) { if (fromDate.equals(date) || toDate.equals(date) || date.after(fromDate) && date.before(toDate)) { retDateList.add(date); } } if (retDateList.size() > 1) { Collections.sort(retDateList); } return retDateList; }
From source file:gov.nasa.arc.spife.ui.table.days.Day.java
public static boolean extentsIntersect(TemporalExtent dayExtent, TemporalExtent elementExtent) { Date dayStart = dayExtent.getStart(); Date elementEnd = elementExtent.getEnd(); if (elementEnd.before(dayStart)) { return false; }// w w w . j a va2 s. c om Date elementStart = elementExtent.getStart(); Date dayEnd = dayExtent.getEnd(); if (elementStart.after(dayEnd)) { return false; } if (elementEnd.equals(dayStart) && !elementStart.equals(dayStart)) { return false; } return true; }