List of usage examples for java.util Date equals
public boolean equals(Object obj)
From source file:org.egov.ptis.client.util.PropertyTaxUtil.java
/** * Checks whether date is between fromDate and toDate or not * * @param date//w w w .j av a 2 s .c o m * @param fromDate * @param toDate * @return true if date is between fromDate and toDate else returns false */ public Boolean between(final Date date, final Date fromDate, final Date toDate) { return (date.after(fromDate) || date.equals(fromDate)) && date.before(toDate) || date.equals(toDate); }
From source file:cimav.client.data.domain.Incidencia.java
public void ajustar() { // Fecha/*from ww w. j a va2s. c o m*/ Date fechaInicioQuin = Quincena.get().getFechaInicio(); Date fechaFinQuin = Quincena.get().getFechaFin(); if (this.getTipo().isIncapacidad()) { // la fecha de inicio para Incapacidades tiene que ser mayor o igual al inicio de la quincena //boolean isAntes = this.fechaInicial.compareTo(fechaInicioQuin) < 0; if (this.fechaInicial.before(fechaInicioQuin)) { this.fechaInicial = fechaInicioQuin; } } else if (this.getTipo().isFalta()) { // la falta tiene que estar entre la fecha de inicio y la fecha de fin de la quincena //boolean isBetween = (this.fechaInicial.compareTo(fechaInicioQuin) >= 0) && (this.fechaInicial.compareTo(fechaFinQuin) <= 0); // incluye endpoints boolean isBetween = (this.fechaInicial.equals(fechaInicioQuin) || this.fechaInicial.after(fechaInicioQuin)) && (this.fechaInicial.equals(fechaFinQuin) || this.fechaInicial.before(fechaFinQuin)); if (!isBetween) { // Si no esta, ajustarla a la fecha de inicio this.fechaInicial = Quincena.get().getFechaInicio(); } } else if (this.getTipo().isPermiso()) { } // Dias if (this.getTipo().isIncapacidad()) { if (this.dias > 90) { // Mximo 90 incapacidades this.dias = 90; } Date fechaAux = this.fechaInicial; this.diasHabiles = 0; this.diasInhabiles = 0; while ((fechaFinQuin.after(fechaAux) || fechaFinQuin.equals(fechaAux)) && ((this.diasHabiles + this.diasInhabiles) < this.dias)) { // mientras no revase a la fecha fin // y mientras Habiles + Inhabibles no superen los dias totales DateTimeFormat format = DateTimeFormat.getFormat("c"); // try with "E" pattern also String dayOfWeek = format.format(fechaAux); //0 for sunday if (dayOfWeek.equals("0") || dayOfWeek.equals("6")) { this.diasInhabiles++; } else { this.diasHabiles++; } // avanzar 1 da fechaAux = new Date(fechaAux.getTime() + TimeUnit.DAYS.toMillis(1)); } } else if (this.getTipo().isFalta()) { if (this.dias > 5) { // Mximo 5 faltas this.dias = 5; } if (this.dias > Quincena.get().getDiasOrdinarios()) { // Mximo igual a los ordinarios this.dias = Quincena.get().getDiasOrdinarios(); } // todas la faltas capturadas son sobre dias hbiles; no hay faltas en das inhabiles o de asueto this.diasHabiles = this.dias; // no hay faltas en das de descanso this.diasInhabiles = 0; } else if (this.getTipo().isPermiso()) { // no cuentan como faltas //this.incidencias = 0; } }
From source file:org.madsonic.service.MediaScannerService.java
private void updateArtist(MediaFile file, Date lastScanned, Map<String, Integer> albumCount, boolean isVariousArtists) { if (file.getAlbumArtist() == null || file.getArtist() == null || !file.isAudio()) { return;// w ww.ja v a 2s. c o m } Artist artist = artistDao.getArtist(file.getArtist()); if (artist == null) { artist = new Artist(); artist.setName(file.getArtist()); } if (artist.getGenre() != file.getGenre()) { artist.setGenre(file.getGenre()); } // if (artist.getCoverArtPath() == null) { // MediaFile parent = mediaFileService.getParentOf(file); // MediaFile grandparent = mediaFileService.getParentOf(parent); // if (grandparent != null) { // artist.setCoverArtPath(grandparent.getCoverArtPath()); // } else // { // if (parent != null) { // artist.setCoverArtPath(parent.getCoverArtPath()); // } // } // } boolean firstEncounter = !lastScanned.equals(artist.getLastScanned()); Integer n = albumCount.get(artist.getName()); artist.setAlbumCount(n == null ? 1 : n); // if (artist.getAlbumCount() == 0) // { artist.setAlbumCount(1); } artist.incrementPlay(file.getPlayCount()); artist.incrementSongs(1); MediaFile parent = mediaFileService.getParentOf(file); MediaFile parentOfParent = mediaFileService.getParentOf(parent); if (parent.isSingleArtist()) { //|| parent.isAlbumSet()){ artist.setArtistFolder(parent.getAlbumArtist()); artist.setCoverArtPath(parent.getCoverArtPath()); } else { if (parentOfParent.isSingleArtist()) { // || parentOfParent.isAlbumSet()){ artist.setArtistFolder(parentOfParent.getAlbumName()); artist.setCoverArtPath(parentOfParent.getCoverArtPath()); } } // artist.setArtistFolder(file.getPath()); artist.setLastScanned(lastScanned); artist.setPresent(true); try { artistDao.createOrUpdateArtist(artist); } catch (Exception x) { LOG.error("Failed to createOrUpdateArtist: " + file.getPath(), x); } if (firstEncounter) { searchService.index(artist); } }
From source file:org.craftercms.cstudio.alfresco.dm.service.impl.DmSimpleWorkflowServiceImpl.java
@Override public void doDelete(String site, String sub, List<DmDependencyTO> submittedItems, String approver) throws ServiceException { long start = System.currentTimeMillis(); PersistenceManagerService persistenceManagerService = getService(PersistenceManagerService.class); String user = persistenceManagerService.getCurrentUserName(); // get web project information String assignee = getAssignee(site, sub); // Don't make go live an item if it is new and to be deleted final Date now = new Date(); List<String> itemsToDelete = new FastList<String>(); List<DmDependencyTO> deleteItems = new FastList<DmDependencyTO>(); List<DmDependencyTO> scheItems = new FastList<DmDependencyTO>(); DmContentService dmContentService = getService(DmContentService.class); for (DmDependencyTO submittedItem : submittedItems) { String uri = submittedItem.getUri(); Date schDate = submittedItem.getScheduledDate(); boolean isItemForSchedule = false; if (schDate == null || schDate.before(now)) { // Sending Notification if (StringUtils.isNotEmpty(approver)) { // immediate delete if (submittedItem.isSendEmail()) { sendDeleteApprovalNotification(site, submittedItem, approver);//TODO move it after delete actually happens }// w w w .j ava 2s. c o m } if (submittedItem.getUri().endsWith(DmConstants.INDEX_FILE)) { submittedItem.setUri(submittedItem.getUri().replace("/" + DmConstants.INDEX_FILE, "")); } itemsToDelete.add(uri); } else { scheItems.add(submittedItem); isItemForSchedule = true; } submittedItem.setDeleted(true); // replace with the folder name boolean isNew = dmContentService.isNew(site, uri); if (!isNew || isItemForSchedule) { deleteItems.add(submittedItem); } NodeRef itemToDelete = persistenceManagerService .getNodeRef(dmContentService.getContentFullPath(site, uri)); if (persistenceManagerService.hasAspect(itemToDelete, CStudioContentModel.ASPECT_RENAMED)) { String oldPath = (String) persistenceManagerService.getProperty(itemToDelete, CStudioContentModel.PROP_RENAMED_OLD_URL); if (oldPath != null) { itemsToDelete.add(oldPath);//Make sure old path is going to be deleted } } } //List<String> deletedItems = deleteInTransaction(site, itemsToDelete); GoLiveContext context = new GoLiveContext(approver, site); //final String pathPrefix = getSiteRoot(site, null); ServicesConfig servicesConfig = getService(ServicesConfig.class); final String pathPrefix = servicesConfig.getRepositoryRootPath(site); Map<Date, List<DmDependencyTO>> groupedPackages = groupByDate(deleteItems, now); if (groupedPackages.isEmpty()) { groupedPackages.put(now, Collections.<DmDependencyTO>emptyList()); } for (Date scheduledDate : groupedPackages.keySet()) { List<DmDependencyTO> deletePackage = groupedPackages.get(scheduledDate); SubmitPackage submitpackage = new SubmitPackage(pathPrefix); Set<String> rescheduledUris = new HashSet<String>(); if (deletePackage != null) { Date launchDate = scheduledDate.equals(now) ? null : scheduledDate; for (DmDependencyTO dmDependencyTO : deletePackage) { if (launchDate != null) { handleReferences(site, submitpackage, dmDependencyTO, true, null, "", rescheduledUris); } else { applyDeleteDependencyRule(site, submitpackage, dmDependencyTO); } } String label = submitpackage.getLabel(); String workFlowName = _submitDirectWorkflowName; SubmitLifeCycleOperation deleteOperation = null; Set<String> liveDependencyItems = new HashSet<String>(); Set<String> allItems = new HashSet<String>(); for (String uri : itemsToDelete) {//$ToDO $ remove this case and keep the item in go live queue GoLiveDeleteCandidates deleteCandidate = dmContentService.getDeleteCandidates(context.getSite(), uri); allItems.addAll(deleteCandidate.getAllItems()); //get all dependencies that has to be removed as well liveDependencyItems.addAll(deleteCandidate.getLiveDependencyItems()); } List<String> submitPackPaths = submitpackage.getPaths(); if (launchDate != null) { deleteOperation = new PreScheduleDeleteOperation(this, submitpackage.getUris(), launchDate, context, rescheduledUris); label = DmConstants.DM_SCHEDULE_SUBMISSION_FLOW + ":" + label; workFlowName = _reviewWorkflowName; for (String submitPackPath : submitpackage.getUris()) { String fullpath = dmContentService.getContentFullPath(site, submitPackPath); _cacheManager.invalidateAndRemoveFromQueue(fullpath, site); } } else { //add dependencies to submitPackage for (String liveDependency : liveDependencyItems) { DmPathTO pathTO = new DmPathTO(liveDependency); submitpackage.addToPackage(pathTO.getRelativePath()); } submitPackPaths = submitpackage.getPaths(); deleteOperation = new PreSubmitDeleteOperation(this, new HashSet<String>(itemsToDelete), context, rescheduledUris); removeChildFromSubmitPackForDelete(submitPackPaths); for (String deleteCandidate : allItems) { //_cacheManager.invalidateAndRemoveFromQueue(deleteCandidate, site); } } Map<String, String> submittedBy = new FastMap<String, String>(); SearchService searchService = getService(SearchService.class); for (String longPath : submitPackPaths) { String uri = longPath.substring(pathPrefix.length()); DmUtils.addToSubmittedByMapping(persistenceManagerService, dmContentService, searchService, site, uri, submittedBy, approver); } _workflowProcessor.addToWorkflow(site, new ArrayList<String>(), launchDate, workFlowName, label, deleteOperation, approver, null); } } if (logger.isDebugEnabled()) { long end = System.currentTimeMillis(); logger.debug("Submitted deleted items to queue time = " + (end - start)); } }
From source file:org.jpos.gl.GLSession.java
/** * @param journal the journal.//from w w w . ja va 2 s. co m * @param start date (inclusive). * @param end date (inclusive). * @param destinationJournal where to move former transactions. A null value would delete former transactions. * @param searchString optional search string * @param findByPostDate true to find by postDate, false to find by timestamp * @param pageNumber the page number * @param pageSize the page size * @return list of transactions * @throws GLException if user doesn't have READ permission on this jounral. */ public List findTransactions(Journal journal, Date start, Date end, String searchString, boolean findByPostDate, int pageNumber, int pageSize) throws HibernateException, GLException { checkPermission(GLPermission.READ, journal); String dateField = findByPostDate ? "postDate" : "timestamp"; if (findByPostDate) { if (start != null) start = Util.floor(start); if (end != null) end = Util.ceil(end); } Criteria crit = session.createCriteria(GLTransaction.class).add(Expression.eq("journal", journal)); if (start != null && start.equals(end)) crit.add(Expression.eq(dateField, start)); else { if (start != null) crit.add(Expression.ge(dateField, start)); if (end != null) crit.add(Expression.le(dateField, end)); } if (searchString != null) crit.add(Expression.like("detail", "%" + searchString + "%")); if (pageSize > 0 && pageNumber > 0) { crit.setMaxResults(pageSize); crit.setFirstResult(pageSize * (pageNumber - 1)); } return crit.list(); }
From source file:org.obm.icalendar.Ical4jHelper.java
@Override public Date isInIntervalDate(EventRecurrence recurrence, Date eventDate, Date start, Date end, Set<Date> dateExce) { List<Date> dates = dateInInterval(recurrence, eventDate, start, end, dateExce); for (Date date : dates) { if ((date.after(start) || date.equals(start)) && (end == null || ((date.before(end) || date.equals(end))))) { return date; }// www . j a v a2 s . c o m } return null; }
From source file:org.atomserver.core.AbstractAtomCollection.java
/** * {@inheritDoc}// ww w . j a va2s . com */ public Entry getEntry(RequestContext request) throws AtomServerException { Abdera abdera = request.getServiceContext().getAbdera(); EntryTarget entryTarget = getEntryTarget(request); if (entryTarget.getRawRevision() != null) { throw new BadRequestException("Do NOT include the revision number when GET-ing an Entry"); } EntryMetaData entryMetaData = getEntry(entryTarget); Date thisLastUpdated = (entryMetaData.getUpdatedDate() != null) ? entryMetaData.getUpdatedDate() : AtomServerConstants.ZERO_DATE; Date updatedMin = getUpdatedMin(entryTarget, request); Date updatedMax = (entryTarget.getUpdatedMaxParam() != null) ? entryTarget.getUpdatedMaxParam() : AtomServerConstants.FAR_FUTURE_DATE; Entry entry = null; if ((thisLastUpdated.after(updatedMin) || thisLastUpdated.equals(updatedMin)) && thisLastUpdated.before(updatedMax)) { EntryType entryType = (entryTarget.getEntryTypeParam() != null) ? entryTarget.getEntryTypeParam() : EntryType.full; entry = newEntry(abdera, entryMetaData, entryType); } return entry; }
From source file:org.sakaiproject.signup.tool.jsf.organizer.EditMeetingSignupMBean.java
/** * This is a validator to make sure that the event/meeting starting time is * before ending time etc./*from w w w . j a v a 2s . c o m*/ * * @param e * an ActionEvent object. */ public void validateModifyMeeting(ActionEvent e) { Date eventEndTime = this.signupMeeting.getEndTime(); Date eventStartTime = this.signupMeeting.getStartTime(); /*user defined own TS case*/ if (isUserDefinedTS()) { eventEndTime = getUserDefineTimeslotBean().getEventEndTime(); eventStartTime = getUserDefineTimeslotBean().getEventStartTime(); if (getUserDefineTimeslotBean().getDestTSwrpList() == null || getUserDefineTimeslotBean().getDestTSwrpList().isEmpty()) { validationError = true; Utilities.addErrorMessage(Utilities.rb.getString("event.create_custom_defined_TS_blocks")); return; } } if (eventEndTime.before(eventStartTime) || eventStartTime.equals(eventEndTime)) { validationError = true; Utilities.addErrorMessage(Utilities.rb.getString("event.endTime_should_after_startTime")); return; } /*for custom defined time slot case*/ if (!validationError && isUserDefinedTS()) { this.signupMeeting.setStartTime(eventStartTime); this.signupMeeting.setEndTime(eventEndTime); this.signupMeeting.setMeetingType(CUSTOM_TIMESLOTS); } if ((DAILY.equals(this.signupMeeting.getRepeatType()) || WEEKDAYS.equals(this.signupMeeting.getRepeatType())) && isMeetingOverRepeatPeriod(this.signupMeeting.getStartTime(), this.signupMeeting.getEndTime(), 1)) { validationError = true; Utilities.addErrorMessage(Utilities.rb.getString("crossDay.event.repeat.daily.problem")); return; } if (WEEKLY.equals(this.signupMeeting.getRepeatType()) && isMeetingOverRepeatPeriod( this.signupMeeting.getStartTime(), this.signupMeeting.getEndTime(), 7)) { validationError = true; Utilities.addErrorMessage(Utilities.rb.getString("crossDay.event.repeat.weekly.problem")); return; } if (BIWEEKLY.equals(this.signupMeeting.getRepeatType()) && isMeetingOverRepeatPeriod( this.signupMeeting.getStartTime(), this.signupMeeting.getEndTime(), 14)) { validationError = true; Utilities.addErrorMessage(Utilities.rb.getString("crossDay.event.repeat.biweekly.problem")); return; } int timeduration = getTimeSlotDuration(); if (timeduration < 1) { validationError = true; Utilities.addErrorMessage(Utilities.rb.getString("event.timeslot_duration_should_not_lessThan_one")); return; } //Set Location if (StringUtils.isBlank(getCustomLocation())) { if (StringUtils.isBlank(selectedLocation) || selectedLocation.equals(Utilities.rb.getString("select_location"))) { validationError = true; Utilities.addErrorMessage(Utilities.rb.getString("event.location_not_assigned")); return; } this.signupMeeting.setLocation(selectedLocation); } else { this.signupMeeting.setLocation(getCustomLocation()); } //clear the location fields??? this.selectedLocation = ""; //Set Category //if textfield is blank, check the dropdown if (StringUtils.isBlank(getCustomCategory())) { //if dropdown is not the default, then use its value if (!StringUtils.equals(selectedCategory, Utilities.rb.getString("select_category"))) { this.signupMeeting.setCategory(selectedCategory); } } else { this.signupMeeting.setCategory(getCustomCategory()); } //clear the category fields?? this.selectedCategory = ""; //set the creator/organiser this.signupMeeting.setCreatorUserId(creatorUserId); this.creatorUserId = ""; }
From source file:org.openmrs.api.FormServiceTest.java
/** * @see FormService#saveFormResource(FormResource) *//* ww w .j ava 2 s .co m*/ @Test @Verifies(value = "should overwrite an existing resource with same name", method = "saveFormResource(FormResource)") public void saveFormResource_shouldOverwriteAnExistingResourceWithSameName() throws Exception { String name = "Start Date"; // save an original resource Form form = Context.getFormService().getForm(1); FormResource resource = new FormResource(); resource.setForm(form); resource.setName(name); resource.setDatatypeClassname("org.openmrs.customdatatype.datatype.DateDatatype"); Date previous = new SimpleDateFormat("yyyy-MM-dd").parse("2011-10-16"); resource.setValue(previous); Context.getFormService().saveFormResource(resource); // clear the session Context.flushSession(); // save a new resource with the same name form = Context.getFormService().getForm(1); resource = new FormResource(); resource.setForm(form); resource.setName(name); resource.setDatatypeClassname("org.openmrs.customdatatype.datatype.DateDatatype"); Date expected = new SimpleDateFormat("yyyy-MM-dd").parse("2010-10-16"); resource.setValue(expected); Context.getFormService().saveFormResource(resource); // get the current value FormResource actual = Context.getFormService().getFormResource(form, name); Assert.assertFalse(previous.equals(actual.getValue())); Assert.assertEquals(expected, actual.getValue()); }
From source file:Servlet.ServImportacaoMovVisual.java
/** * Handles the HTTP <code>GET</code> method. * * @param request servlet request/* w w w . j ava 2s . co m*/ * @param response servlet response * @throws ServletException if a servlet-specific error occurs * @throws IOException if an I/O error occurs */ @Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { HttpSession sessao = request.getSession(); String expira = (String) sessao.getAttribute("empresa"); if (expira == null) { response.sendRedirect("/index.jsp?msgLog=3"); } else { try { String nomeBD = (String) sessao.getAttribute("empresa"); boolean isMultiPart = FileUpload.isMultipartContent(request); if (isMultiPart) { FileItemFactory factory = new DiskFileItemFactory(); ServletFileUpload upload = new ServletFileUpload(factory); upload.setSizeMax(1024 * 1024 * 2); String vData1 = "", vData2 = ""; String vCaminho = ""; int idUsuario = 0; Date data1 = null, data2 = null; List items = upload.parseRequest(request); Iterator iter = items.iterator(); FileItem itemImg = (FileItem) iter.next(); while (iter.hasNext()) { FileItem item = (FileItem) iter.next(); if (item.isFormField()) { if (item.getFieldName().equals("data")) { vData1 = item.getString(); data1 = FormatarData.formataRetornaDate(vData1); } else if (item.getFieldName().equals("data2")) { vData2 = item.getString(); data2 = FormatarData.formataRetornaDate(vData2); } else if (item.getFieldName().equals("idUsuario")) { idUsuario = Integer.parseInt(item.getString()); } } if (!item.isFormField()) { if (item.getName().length() > 0) { itemImg = item; } } } vCaminho = "";//inserirDiretorio(itemImg); if (vCaminho.equals("")) { sessao.setAttribute("msg", "Escolha um arquivo para importacao!"); } else { if (data1 != null && data2 != null && (data1.before(data2) || data1.equals(data2)) && Util.SomaData.diferencaEmDias(data1, data2) <= 31) { String mensagem = importaMovimento(itemImg, data1, nomeBD, idUsuario); sessao.setAttribute("msg", mensagem); } else { sessao.setAttribute("msg", "Data incorreta, ou periodo maior que 1 mes!"); } } } } catch (FileUploadBase.SizeLimitExceededException e) { sessao.setAttribute("msg", "Tamanho Mximo do Arquivo Excedido!"); } catch (FileUploadException ex) { int idErro = ContrErroLog.inserir("HOITO - ServImportacaoMov", "FileUploadException", null, ex.toString()); sessao.setAttribute("msg", "SYSTEM ERROR N: " + idErro + "; Ocorreu um erro inesperado!"); } catch (Exception ex) { int idErro = ContrErroLog.inserir("HOITO - ServImportacaoMov", "Exception", null, ex.toString()); sessao.setAttribute("msg", "SYSTEM ERROR N: " + idErro + "; Ocorreu um erro inesperado!"); } //response.sendRedirect("./Agencia/Importacao/imp_movimento_visual.jsp"); response.sendRedirect(request.getHeader("referer")); } }