List of usage examples for java.util Date equals
public boolean equals(Object obj)
From source file:com.projity.util.SpecialDateFormat.java
public StringBuffer format(Date date, StringBuffer arg1, FieldPosition arg2) { if (date.equals(DateTime.getMaxDate())) { arg1.append(NO_END);//from ww w. j av a 2 s .com return arg1; } else if (date.equals(DateTime.NA_TIME)) { arg1.append(NO_START); return arg1; } return defaultInstance.format(date, arg1, arg2); // return super.format(date, arg1, arg2); }
From source file:org.bahmni.module.bahmnicore.db.hibernate.DropMillisecondsHibernateInterceptor.java
/** * If any item in fieldValues is a Date with non-zero milliseconds, it is replaced with the Date corresponding to * the same second, with no milliseconds. * * @param fieldValues// ww w. ja va 2 s. c o m * @return whether anything was modified */ private boolean removeMillisecondsFromDateFields(Object[] fieldValues) { boolean anyChanges = false; for (int i = fieldValues.length - 1; i >= 0; --i) { Object candidate = fieldValues[i]; if (candidate instanceof Date) { Date noMilliseconds = removeMilliseconds((Date) candidate); if (!noMilliseconds.equals(candidate)) { fieldValues[i] = noMilliseconds; anyChanges = true; } } } return anyChanges; }
From source file:org.codice.alliance.nsili.common.ResultDAGConverter.java
public static List<String> addCardNodeWithAttributes(DirectedAcyclicGraph<Node, Edge> graph, Node productNode, Metacard metacard, ORB orb, String parentAttrName, List<String> resultAttributes) { List<String> addedAttributes = new ArrayList<>(); Any any = orb.create_any();//from www . j a v a2 s .c o m Node cardNode = new Node(0, NodeType.ENTITY_NODE, NsiliConstants.NSIL_CARD, any); graph.addVertex(cardNode); graph.addEdge(productNode, cardNode); String attribute = parentAttrName + NsiliConstants.NSIL_CARD; if (shouldAdd(buildAttr(attribute, NsiliConstants.IDENTIFIER), resultAttributes) && metacard.getId() != null) { addStringAttribute(graph, cardNode, NsiliConstants.IDENTIFIER, metacard.getId(), orb); addedAttributes.add(buildAttr(attribute, NsiliConstants.IDENTIFIER)); } if (metacard.getCreatedDate() != null) { if (shouldAdd(buildAttr(attribute, NsiliConstants.SOURCE_DATE_TIME_MODIFIED), resultAttributes)) { addDateAttribute(graph, cardNode, NsiliConstants.SOURCE_DATE_TIME_MODIFIED, metacard.getCreatedDate(), orb); addedAttributes.add(buildAttr(attribute, NsiliConstants.SOURCE_DATE_TIME_MODIFIED)); } if (shouldAdd(buildAttr(attribute, NsiliConstants.DATE_TIME_MODIFIED), resultAttributes)) { addDateAttribute(graph, cardNode, NsiliConstants.DATE_TIME_MODIFIED, metacard.getCreatedDate(), orb); addedAttributes.add(buildAttr(attribute, NsiliConstants.DATE_TIME_MODIFIED)); } } if (shouldAdd(buildAttr(attribute, NsiliConstants.SOURCE_LIBRARY), resultAttributes)) { if (StringUtils.isNotBlank(metacard.getSourceId())) { addStringAttribute(graph, cardNode, NsiliConstants.SOURCE_LIBRARY, metacard.getSourceId(), orb); } else { addStringAttribute(graph, cardNode, NsiliConstants.SOURCE_LIBRARY, NsiliConstants.UNKNOWN, orb); } addedAttributes.add(buildAttr(attribute, NsiliConstants.SOURCE_LIBRARY)); } if (shouldAdd(buildAttr(attribute, NsiliConstants.STATUS), resultAttributes)) { String status = NsiliCardStatus.CHANGED.name(); Attribute createdAttr = metacard.getAttribute(Core.METACARD_CREATED); Attribute modifiedAttr = metacard.getAttribute(Core.METACARD_MODIFIED); if (createdAttr != null && modifiedAttr != null) { Date createdDate = (Date) createdAttr.getValue(); Date modifiedDate = (Date) modifiedAttr.getValue(); if (createdDate.equals(modifiedDate)) { status = NsiliCardStatus.NEW.name(); } } Attribute versionAction = metacard.getAttribute(MetacardVersion.ACTION); if (versionAction != null) { for (Serializable action : versionAction.getValues()) { if (action.toString().trim().equals(MetacardVersion.Action.DELETED.getKey())) { status = NsiliCardStatus.OBSOLETE.name(); break; } } } addStringAttribute(graph, cardNode, NsiliConstants.STATUS, status, orb); addedAttributes.add(buildAttr(attribute, NsiliConstants.STATUS)); } return addedAttributes; }
From source file:com.microsoft.projectoxford.face.samples.helper.StorageHelper.java
public static ArrayList<String> runQuery(String from, String to, String courseId) { ArrayList<ParseObject> listTrainings = new ArrayList<>(); ArrayList<String> list = new ArrayList<>(); ParseQuery<ParseObject> query = ParseQuery.getQuery("List"); query.whereEqualTo("Code", courseId); try {/*from w ww .j av a 2s . c o m*/ listTrainings = (ArrayList<ParseObject>) (query.find()); } catch (com.parse.ParseException e) { e.printStackTrace(); } SimpleDateFormat sdf = new SimpleDateFormat("dd/MM/yyyy"); Date date, toDate, fromDate; for (ParseObject course : listTrainings) { try { date = sdf.parse(course.get("Date").toString()); toDate = sdf.parse(to); fromDate = sdf.parse(from); if ((date.after(fromDate) && toDate.after(date)) || date.equals(fromDate) || date.equals(toDate)) { list.add(course.get("Names").toString()); } } catch (ParseException e) { e.printStackTrace(); } } return list; }
From source file:com.jdom.get.stuff.done.domain.DueWithinDatesFilterOption.java
@Override public String toString() { String dateSuffix = null;/*from www.ja va 2 s . c om*/ if (latest.equals(earliest)) { Date today = DateUtil.getCurrentDateZeroingHoursAndBelow(); if (today.equals(earliest)) { dateSuffix = TODAY; } else { dateSuffix = TOMORROW; } } else if (latest.getTime() == (earliest.getTime() + Constants.MILLIS_PER_WEEK)) { dateSuffix = THIS_WEEK; } return FILTER_PREFIX + dateSuffix; }
From source file:edu.psu.iam.cpr.core.util.Utility.java
/** * This method is used to compare dates for equality. * * @param parm1 contains the first date to be compared. * @param parm2 contains the second date to be compared. * @return will return true if the dates are equal, otherwise it will return false. */// ww w . j a v a 2 s. c o m public static boolean areDateFieldsEqual(final Date parm1, final Date parm2) { try { if (parm1 == null && parm2 == null) { return true; } else if (parm1 == null && parm2 != null || parm1 != null && parm2 == null) { return false; } else { return parm1.equals(parm2); } } catch (final Exception e) { return false; } }
From source file:org.openmrs.module.emrapi.encounter.EncounterTransactionMapper.java
private boolean shouldNotCompareOnCreatedDates(Date secondDate, Date firstDate) { return firstDate == null || secondDate == null || secondDate.equals(firstDate); }
From source file:uk.co.thinkofdeath.thinkcraft.bukkit.web.ResourcesServer.java
@Override public void handle(ChannelHandlerContext context, URI uri, FullHttpRequest request) throws Exception { File file = new File(plugin.getResourceDir(), uri.getPath().substring("/resources/".length())); if (!file.exists()) { sendHttpResponse(context, request, new DefaultFullHttpResponse(HTTP_1_1, NOT_FOUND)); return;/*w w w . j a v a 2 s . co m*/ } String modified = request.headers().get(IF_MODIFIED_SINCE); if (modified != null && !modified.isEmpty()) { Date modifiedDate = format.parse(modified); if (modifiedDate.equals(plugin.getStartUpDate())) { sendHttpResponse(context, request, new DefaultFullHttpResponse(HTTP_1_1, NOT_MODIFIED)); return; } } ByteBuf buffer; try (InputStream stream = new FileInputStream(file)) { ByteBufOutputStream out = new ByteBufOutputStream(context.alloc().buffer()); IOUtils.copy(stream, out); buffer = out.buffer(); out.close(); } FullHttpResponse response = new DefaultFullHttpResponse(HTTP_1_1, OK, buffer); response.headers().set(DATE, format.format(new Date())); response.headers().set(LAST_MODIFIED, format.format(plugin.getStartUpDate())); if (uri.getPath().startsWith("/resources/assets")) { Calendar calendar = Calendar.getInstance(); calendar.setTime(new Date()); calendar.add(Calendar.MONTH, 1); response.headers().set(EXPIRES, format.format(calendar.getTime())); response.headers().set(CACHE_CONTROL, "public, max-age=2592000"); } String path = uri.getPath(); String ext = path.substring(path.lastIndexOf('.') + 1); String type = mimeTypes.containsKey(ext) ? mimeTypes.get(ext) : "text/plain"; if (type.startsWith("text/")) { type += "; charset=UTF-8"; } response.headers().set(CONTENT_TYPE, type); response.headers().add("Access-Control-Allow-Origin", "*"); sendHttpResponse(context, request, response); }
From source file:edu.toronto.cs.cidb.listeners.PatientBirthdateUpdater.java
@Override public void onEvent(Event event, Object source, Object data) { XWikiDocument doc = (XWikiDocument) source; BaseObject patientRecordObj = doc.getXObject(new DocumentReference( doc.getDocumentReference().getRoot().getName(), "ClinicalInformationCode", "PatientClass")); if (patientRecordObj == null) { return;//from w w w .j ava 2s . c o m } String targetPropertyName = "date_of_birth"; int year = getParameter("date_of_birth_year", patientRecordObj.getNumber()); int month = getParameter("date_of_birth_month", patientRecordObj.getNumber()); int day = getParameter("date_of_birth_day", patientRecordObj.getNumber()); if (year == -1 || month == -1) { // No values specified in the request, skip this step return; } if (day <= 0) { day = 1; } Date birthdate = patientRecordObj.getDateValue(targetPropertyName); Date newBirthdate = new GregorianCalendar(year, month, day).getTime(); if (!newBirthdate.equals(birthdate)) { patientRecordObj.setDateValue(targetPropertyName, newBirthdate); } }
From source file:edu.toronto.cs.phenotips.listeners.PatientBirthdateUpdater.java
@Override public void onEvent(Event event, Object source, Object data) { XWikiDocument doc = (XWikiDocument) source; BaseObject patientRecordObj = doc.getXObject( new DocumentReference(doc.getDocumentReference().getRoot().getName(), "PhenoTips", "PatientClass")); if (patientRecordObj == null) { return;/*from ww w. jav a 2s . co m*/ } String targetPropertyName = "date_of_birth"; int year = getParameter("date_of_birth_year", patientRecordObj.getNumber()); int month = getParameter("date_of_birth_month", patientRecordObj.getNumber()); int day = getParameter("date_of_birth_day", patientRecordObj.getNumber()); if (year == -1 || month == -1) { // No values specified in the request, skip this step return; } if (day <= 0) { day = 1; } Date birthdate = patientRecordObj.getDateValue(targetPropertyName); Date newBirthdate = new GregorianCalendar(year, month, day).getTime(); if (!newBirthdate.equals(birthdate)) { patientRecordObj.setDateValue(targetPropertyName, newBirthdate); } }