List of usage examples for java.util Date equals
public boolean equals(Object obj)
From source file:org.openmrs.module.kenyaemr.chore.HivEnrollmentEncounterDateSynched.java
/** * @see org.openmrs.module.kenyacore.chore.AbstractChore#perform(java.io.PrintWriter) *///from ww w . j a va2 s . co m @Override public void perform(PrintWriter out) { Form MOH_257_FACE_PAGE_ENCOUNTER_FORM = formService.getFormByUuid(HivMetadata._Form.MOH_257_FACE_PAGE); Form HIV_ENROLLMENT_FORM = formService.getFormByUuid(HivMetadata._Form.HIV_ENROLLMENT); Concept concept = Dictionary.getConcept(Dictionary.DATE_ENROLLED_IN_HIV_CARE); EncounterType encounterType = encounterService .getEncounterTypeByUuid(HivMetadata._EncounterType.HIV_ENROLLMENT); //find a list of encounter per MOH_257_FACE_PAGE_ENCOUNTER_FORM and encounterType List<Encounter> encounters = encounterService.getEncounters(null, null, null, null, Arrays.asList(MOH_257_FACE_PAGE_ENCOUNTER_FORM, HIV_ENROLLMENT_FORM), Arrays.asList(encounterType), null, null, null, false); int count = 0; int found_matching = 0; // list of all obs Set<Obs> obsList; Date encounter_date; Date obs_value_date; for (Encounter encounter : encounters) { encounter_date = encounter.getEncounterDatetime(); obsList = encounter.getAllObs(false); for (Obs obs : obsList) { if (obs.getConcept().equals(concept)) { found_matching++; obs_value_date = obs.getValueDatetime(); if (!(encounter_date.equals(obs_value_date))) { encounter.setEncounterDatetime(obs.getValueDatetime()); count++; } } } } out.println("Matching found " + found_matching + " observations"); out.println("Adjusted " + count + " encounters to reflect date first enrolled into care"); }
From source file:com.xpn.xwiki.web.XWikiMessageTool.java
/** * @return the internationalization document bundles (a list of {@XWikiDocument}) * @see com.xpn.xwiki.web.XWikiMessageTool for more details on the algorithm used to find the document bundles *//*from w w w . ja va 2s.c o m*/ public List<XWikiDocument> getDocumentBundles() { String defaultLanguage = this.context.getWiki().getDefaultLanguage(this.context); List<XWikiDocument> result = new ArrayList<XWikiDocument>(); for (String docName : getDocumentBundleNames()) { for (XWikiDocument docBundle : getDocumentBundles(docName.trim(), defaultLanguage)) { if (docBundle != null) { if (!docBundle.isNew()) { // Checks for a name update Long docId = new Long(docBundle.getId()); Date docDate = docBundle.getDate(); // Check for a doc modification if (!docDate.equals(this.previousDates.get(docId))) { this.docsToRefresh.add(docId); this.previousDates.put(docId, docDate); } result.add(docBundle); } else { // The document listed as a document bundle doesn't exist. Do nothing // and log. LOGGER.warn("The document [" + docBundle.getFullName() + "] is listed " + "as an internationalization document bundle but it does not " + "exist."); } } } } return result; }
From source file:org.codelabor.common.calendar.services.AbstractCalendarServiceImpl.java
/** * ?? ?, ?? ? ?./* w w w . j a v a2 s . c o m*/ * * @param date * ? * @return ? */ protected boolean isInRange(Date date) { Assert.notNull(date); return ((date.equals(dateRangeFrom) || date.after(dateRangeFrom)) && (date.equals(dateRangeTo) || date.before(dateRangeTo))); }
From source file:org.kalypso.model.hydrology.internal.preprocessing.writer.TsFileWriter.java
/** * Very specialized: we have a special factor for precipitation in the forecast date range.<br/> * This makes actually only sense for highwater prediction. *//*from ww w .ja va 2s. com*/ private RangeFactor createForecastFactor(final Catchment catchment) { // FIXME: cannot work any more final Date startForecast = m_metaControl.getSimulationEnd(); if (startForecast == null) return null; final Date simulationEnd = m_metaControl.getSimulationEnd(); if (startForecast.equals(simulationEnd)) return null; if (m_naOptimize == null) return null; final IFeatureBindingCollection<Catchment> catchmentCollection = m_naOptimize.getCatchmentCollection(); if (!catchmentCollection.contains(catchment)) return null; final double faktn = catchment.getFaktn(); final double faktnPrognose = m_naOptimize.getFaktnPrognose(); // THE BIG HACK: We always devide by the catchment factor, else we would get two factors: the catchment factor // (applied by kalypso-na.exe) AND the forecast factor. But we only want one factor. final double forcastFactorN = faktnPrognose / faktn; final DateRange forecastRange = new DateRange(startForecast, simulationEnd); return new RangeFactor(forecastRange, forcastFactorN); }
From source file:com.github.pockethub.android.ui.gist.GistFragment.java
private void updateHeader(Gist gist) { Date createdAt = gist.createdAt(); if (createdAt != null) { StyledText text = new StyledText(); text.append(getString(R.string.prefix_created)); text.append(createdAt);/* w w w.j a v a 2 s .c o m*/ created.setText(text); created.setVisibility(VISIBLE); } else { created.setVisibility(GONE); } Date updatedAt = gist.updatedAt(); if (updatedAt != null && !updatedAt.equals(createdAt)) { StyledText text = new StyledText(); text.append(getString(R.string.prefix_updated)); text.append(updatedAt); updated.setText(text); updated.setVisibility(VISIBLE); } else { updated.setVisibility(GONE); } String desc = gist.description(); if (!TextUtils.isEmpty(desc)) { description.setText(desc); } else { description.setText(R.string.no_description_given); } progress.setVisibility(GONE); list.setVisibility(VISIBLE); }
From source file:com.microsoft.tfs.client.common.ui.wit.form.controls.DateTimeControlFieldChangeListener.java
public void fieldChangedSafe(final FieldChangeEvent event) { /*/*from www .j av a2 s . c o m*/ * the work item field that has changed */ final Field field = event.field; final String messageFormat = "DateTimeControlFieldChangeListener called for field change on [{0}]"; //$NON-NLS-1$ final String message = MessageFormat.format(messageFormat, Integer.toString(field.getID())); log.trace(message); /* * remove the modify listener from the combo to avoid triggering it when * we call modify the UI */ final ModifyListener modifyListener = (ModifyListener) datepickerCombo.getData(modifyListenerWidgetDataKey); if (modifyListener != null) { datepickerCombo.removeModifyListener(modifyListener); } if (!datepickerCombo.getTextControl().isFocusControl()) { if (field.getStatus() != FieldStatus.INVALID_TYPE && field.getStatus() != FieldStatus.INVALID_DATE) { final Date newValue = (Date) field.getValue(); boolean needToSet = true; if (datepickerCombo.isValid()) { final Date currentValue = datepickerCombo.getDate(); if (newValue == null) { needToSet = (currentValue != null); } else { needToSet = !(newValue.equals(currentValue)); } } if (needToSet) { datepickerCombo.setDate(newValue); } } } /* * set the background color of the text control depending on whether or * not the work item field is currently valid */ if (field.getStatus() != FieldStatus.VALID) { datepickerCombo.setBackground(Display.getCurrent().getSystemColor(SWT.COLOR_INFO_BACKGROUND)); if (!datepickerCombo.getTextControl().isFocusControl()) { RequiredDecorationFocusListener.addDecoration(field, datepickerCombo.getTextControl(), null); } } else { datepickerCombo.setBackground(null); if (!datepickerCombo.getTextControl().isFocusControl()) { RequiredDecorationFocusListener.removeDecoration(datepickerCombo.getTextControl(), null); } } /* * re-add the modify listener we temporarily removed */ if (modifyListener != null) { datepickerCombo.addModifyListener(modifyListener); } }
From source file:com.liferay.portal.security.ldap.internal.exportimport.LDAPUserExporterImpl.java
@Override public void exportUser(User user, Map<String, Serializable> userExpandoAttributes) throws Exception { if (user.isDefaultUser() || (user.getStatus() != WorkflowConstants.STATUS_APPROVED)) { return;//from w w w.j a v a2 s . c om } long companyId = user.getCompanyId(); if (!_ldapSettings.isExportEnabled(companyId)) { return; } long ldapServerId = _portalLDAP.getLdapServerId(companyId, user.getScreenName(), user.getEmailAddress()); LdapContext ldapContext = _portalLDAP.getContext(ldapServerId, companyId); try { if (ldapContext == null) { return; } Properties userMappings = _ldapSettings.getUserMappings(ldapServerId, companyId); Properties userExpandoMappings = _ldapSettings.getUserExpandoMappings(ldapServerId, companyId); Binding binding = _portalLDAP.getUser(ldapServerId, user.getCompanyId(), user.getScreenName(), user.getEmailAddress(), true); if (binding == null) { binding = addUser(ldapServerId, ldapContext, user, userMappings); } else { Attributes attributes = _portalLDAP.getUserAttributes(ldapServerId, companyId, ldapContext, binding.getNameInNamespace()); String modifyTimestamp = LDAPUtil.getAttributeString(attributes, "modifyTimestamp"); if (Validator.isNotNull(modifyTimestamp)) { Date modifiedDate = LDAPUtil.parseDate(modifyTimestamp); if (modifiedDate.equals(user.getModifiedDate())) { if (_log.isDebugEnabled()) { _log.debug("Skipping user " + user.getEmailAddress() + " because he is already synchronized"); } return; } } } Name name = new CompositeName(); name.add(binding.getNameInNamespace()); Modifications modifications = _portalToLDAPConverter.getLDAPUserModifications(user, userExpandoAttributes, userMappings, userExpandoMappings); if (modifications == null) { return; } ModificationItem[] modificationItems = modifications.getItems(); ldapContext.modifyAttributes(name, modificationItems); if (!_ldapSettings.isExportGroupEnabled(companyId)) { return; } List<UserGroup> userGroups = _userGroupLocalService.getUserUserGroups(user.getUserId()); for (UserGroup userGroup : userGroups) { exportUser(user.getUserId(), userGroup.getUserGroupId(), UserOperation.ADD); } Modifications groupModifications = _portalToLDAPConverter.getLDAPUserGroupModifications(ldapServerId, userGroups, user, userMappings); ModificationItem[] groupModificationItems = groupModifications.getItems(); if (groupModificationItems.length > 0) { ldapContext.modifyAttributes(name, groupModificationItems); } } catch (NameNotFoundException nnfe) { LDAPAuthConfiguration ldapAuthConfiguration = _ldapAuthConfigurationProvider .getConfiguration(companyId); if (ldapAuthConfiguration.required()) { throw nnfe; } _log.error(nnfe, nnfe); } finally { if (ldapContext != null) { ldapContext.close(); } } }
From source file:net.sourceforge.tagsea.instrumentation.network.NetworkSendJob.java
private File[] gatherFiles() { Date lastSendDate = InstrumentationPreferences.getLastSendDate(); Date today = DateUtils.today(); IPath stateLocation = TagSEAInstrumentationPlugin.getDefault().getStateLocation(); DateFormat format = DateUtils.getDateFormat(); File statePath = stateLocation.toFile(); String[] files = statePath.list(); ArrayList<File> filesList = new ArrayList<File>(); for (String fileName : files) { File file = new File(statePath, fileName); if (file.exists() && !file.isDirectory() && !fileName.endsWith(".zip")) { int firstDot = fileName.indexOf('.'); if (firstDot != -1) { String dateString = fileName.substring(0, firstDot); dateString = dateString.replace('-', '/'); try { Date fileDate = format.parse(dateString); //@tag tagsea.bug.175.fix -author="Del Myers" -date="enCA:31/07/07" : send files that are equal to the last send date as well. if (fileDate.before(today) && (fileDate.after(lastSendDate) || fileDate.equals(lastSendDate))) { filesList.add(file); }//from www. j a v a 2 s . co m } catch (ParseException e) { } } } } return filesList.toArray(new File[filesList.size()]); }
From source file:net.sf.statcvs.output.xml.chart.ModuleActivityChart.java
private ContourDataset createDataset() { List dirs = content.getDirectories(); List dateList = new ArrayList(); Date firstDate = content.getFirstDate(); Date lastDate = content.getLastDate(); Calendar cal = new GregorianCalendar(); cal.setTime(firstDate);/* ww w .jav a2 s . c o m*/ while (cal.getTime().before(lastDate)) { dateList.add(cal.getTime()); cal.add(Calendar.DATE, 1); } dateList.add(lastDate); Double[][] values = new Double[dateList.size()][dirs.size()]; for (int i = 0; i < dateList.size(); i++) { Iterator dirsIt = dirs.iterator(); IntegerMap changesMap = new IntegerMap(); while (dirsIt.hasNext()) { Directory dir = (Directory) dirsIt.next(); RevisionIterator revIt = new RevisionSortIterator(dir.getRevisionIterator()); while (revIt.hasNext()) { CvsRevision rev = revIt.next(); Date revDate = rev.getDate(); Date currDate = (Date) dateList.get(i); Date nextDate = null; if (i < dateList.size() - 1) { nextDate = (Date) dateList.get(i + 1); } if (revDate.equals(currDate) || (revDate.after(currDate) && revDate.before(nextDate))) { changesMap.inc(dir); } } } Iterator cIt = changesMap.iteratorSortedByKey(); while (cIt.hasNext()) { Directory dir = (Directory) cIt.next(); int dirIndex = dirs.indexOf(dir); //values[i][dirIndex] = new Double(changesMap.getPercent(dir)); values[i][dirIndex] = new Double(changesMap.getPercentOfMaximum(dir)); } } int numValues = dateList.size() * dirs.size(); Date[] oDateX = new Date[numValues]; Double[] oDoubleY = new Double[numValues]; Double[] oDoubleZ = new Double[numValues]; for (int x = 0; x < dateList.size(); x++) { for (int y = 0; y < dirs.size(); y++) { int index = (x * dirs.size()) + y; oDateX[index] = (Date) dateList.get(x); oDoubleY[index] = new Double(y); if ((values[x][y] != null) && ((values[x][y].isNaN()) || (values[x][y].equals(new Double(0))))) { values[x][y] = null; } oDoubleZ[index] = values[x][y]; } } oDoubleZ[0] = new Double(0.0); return new DefaultContourDataset(getTitle(), oDateX, oDoubleY, oDoubleZ); }
From source file:org.eclipse.mylyn.reviews.connector.query.SimpleQueryEngine.java
protected boolean isSatisifed(QueryOperation operation, Object candidateValue, String testValue) { if (operation == QueryOperation.MATCH_ITEMS) { if (candidateValue instanceof Enumerator) { Enumerator literal = (Enumerator) candidateValue; String[] items = StringUtils.split(testValue, EmfQueryEngine.LIST_ITEM_SEPERATOR); for (String item : items) { if (item.equals(literal.getName())) { return true; }/*from w w w . j a v a 2s . com*/ } } return false; } if (operation == QueryOperation.EXACT) { return candidateValue.equals(testValue); } if (operation == QueryOperation.NOT_EQUALS) { return !candidateValue.equals(testValue); } if (candidateValue instanceof String) { String stringValue = (String) candidateValue; if (operation == QueryOperation.SUBSTRING) { return stringValue.indexOf(testValue) > 0; } if (operation == QueryOperation.REGEXP) { Pattern pattern = Pattern.compile(testValue); return pattern.matcher(stringValue).matches(); } if (operation == QueryOperation.NOT_REGEXP) { Pattern pattern = Pattern.compile(testValue); return !pattern.matcher(stringValue).matches(); } } if (candidateValue instanceof Date) { EmfAttributeMapper attributeMapper = getConnector().getEmfMapper(getRepository()); Date candidateDate = (Date) candidateValue; if (operation == QueryOperation.IN_RANGE) { String[] dateParts = StringUtils.split(testValue, ","); Date after = attributeMapper.getDateValue(dateParts[0]); Date before = attributeMapper.getDateValue(dateParts[1]); return (candidateDate.after(after) && candidateDate.before(before)) || candidateDate.equals(after) || candidateDate.equals(before); } if (operation == QueryOperation.AFTER) { Date upto = attributeMapper.getDateValue(testValue); return candidateDate.after(upto) || candidateDate.equals(upto); } if (operation == QueryOperation.BEFORE) { Date upto = attributeMapper.getDateValue(testValue); return candidateDate.before(upto) || candidateDate.equals(upto); } } return false; }