List of usage examples for java.util Calendar after
public boolean after(Object when)
Calendar
represents a time after the time represented by the specified Object
. From source file:com.gsr.myschool.server.job.impl.ExpiredDossierJobImpl.java
@Override public void work() { SimpleDateFormat dateformat = new SimpleDateFormat(GlobalParameters.DATE_FORMAT); logger.info("Job started at " + dateformat.format(new Date())); int number = 0; DossierFilterDTO filter = new DossierFilterDTO(); filter.setStatus(DossierStatus.CREATED); List<Dossier> dossiers = dossierService.findAllDossiersByCriteria(filter, null, null).getDossiers(); for (Dossier dossier : dossiers) { // ne supprimer que les dossier cres non soumis des filieres generales if (dossier.getFiliere() != null && dossier.getFiliere().getId().longValue() >= GlobalParameters.PREPA_FILIERE_FROM) continue; if (dossier.getCreateDate() != null) { Calendar date = new GregorianCalendar(); date.setTime(dossier.getCreateDate()); date.add(Calendar.DAY_OF_WEEK_IN_MONTH, 1); Calendar deleteAfterThis = new GregorianCalendar(); if (deleteAfterThis.after(date)) { logger.info("deleting dossier id : " + dossier.getId() + "."); try { inscriptionService.deleteInscription(dossier.getId()); number++;// w w w . j av a 2 s . c o m } catch (Exception e) { logger.fatal(e.getMessage()); } } } } logger.info("Job ended at " + dateformat.format(new Date()) + " with " + number + " Dossier deleted"); }
From source file:freebase.api.FreebaseAPIMusic.java
public static void FetchingFromGoogleAPI() { int max_step = 1; int step = 0; int month_step = 1; Calendar last_date = Calendar.getInstance(); last_date.set(Calendar.YEAR, 2016); last_date.set(Calendar.MONTH, 0); last_date.set(Calendar.DAY_OF_MONTH, 1); Calendar from_date = Calendar.getInstance(); from_date.set(Calendar.YEAR, 2000); from_date.set(Calendar.MONTH, 0); from_date.set(Calendar.DAY_OF_MONTH, 1); Calendar to_date = (Calendar) from_date.clone(); to_date.add(Calendar.MONTH, month_step); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); while (true) { // if (step > max_step) { // break; // } // System.out.println(">>> Cursor = " + current_cursor); // if (/*films == null || films.isEmpty() ||*/step == max_step) { // System.out.println("Films is null or zero size. Break."); // break; // } if (from_date.after(last_date)) { System.out.println("Date is after last date"); break; }//from w w w . j a v a 2 s . co m String fromDate = sdf.format(from_date.getTime()); String toDate = sdf.format(to_date.getTime()); System.out.println(step + " ) fetch films from " + fromDate + " to " + toDate); step++; List<Recording> recordings = getRecording(fromDate, toDate); System.out.println("Films#: " + recordings.size()); writeToFiles(recordings); // for (Film f : films) { // System.out.println(f); // } from_date.add(Calendar.MONTH, month_step); to_date.add(Calendar.MONTH, month_step); } }
From source file:com.xpn.xwiki.plugin.chronopolys.Utils.java
/** * Calculates the number of days between two calendar days * @param d1 The first date./*from w w w. j a v a2 s .c o m*/ * @param d2 The second date. * @return The number of days between the two dates. Zero is * returned if the dates are the same, one if the dates are * adjacent, etc. * If Calendar types of d1 and d2 * are different, the result may not be accurate. */ public int getDaysBetween(java.util.Calendar d1, java.util.Calendar d2) { boolean neg = false; if (d1.after(d2)) { // swap dates so that d1 is start and d2 is end java.util.Calendar swap = d1; d1 = d2; d2 = swap; neg = true; } int days = d2.get(java.util.Calendar.DAY_OF_YEAR) - d1.get(java.util.Calendar.DAY_OF_YEAR); int y2 = d2.get(java.util.Calendar.YEAR); if (d1.get(java.util.Calendar.YEAR) != y2) { d1 = (java.util.Calendar) d1.clone(); do { days += d1.getActualMaximum(java.util.Calendar.DAY_OF_YEAR); d1.add(java.util.Calendar.YEAR, 1); } while (d1.get(java.util.Calendar.YEAR) != y2); } if (neg) return (-1) * days; return days; }
From source file:freebase.api.FreebaseAPI.java
public static void FetchingFromGoogleAPI() { int max_step = 1; int step = 0; int month_step = 1; Calendar last_date = Calendar.getInstance(); last_date.set(Calendar.YEAR, 2016); last_date.set(Calendar.MONTH, 0); last_date.set(Calendar.DAY_OF_MONTH, 1); Calendar from_date = Calendar.getInstance(); from_date.set(Calendar.YEAR, 2010); from_date.set(Calendar.MONTH, 0); from_date.set(Calendar.DAY_OF_MONTH, 1); Calendar to_date = (Calendar) from_date.clone(); to_date.add(Calendar.MONTH, month_step); SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd"); while (true) { // if (step > max_step) { // break; // } // System.out.println(">>> Cursor = " + current_cursor); // if (/*films == null || films.isEmpty() ||*/step == max_step) { // System.out.println("Films is null or zero size. Break."); // break; // } if (from_date.after(last_date)) { System.out.println("Date is after last date"); break; }//from w ww .ja v a 2s .c o m String fromDate = sdf.format(from_date.getTime()); String toDate = sdf.format(to_date.getTime()); System.out.println(step + " ) fetch films from " + fromDate + " to " + toDate); step++; List<Film> films = getFilms(fromDate, toDate); System.out.println("Films#: " + films.size()); writeToFiles(films); // for (Film f : films) { // System.out.println(f); // } from_date.add(Calendar.MONTH, month_step); to_date.add(Calendar.MONTH, month_step); } }
From source file:org.kuali.kra.iacuc.onlinereview.authorization.ModifyIacucProtocolOnlineReviewTypeAuthorizer.java
/** * @see org.kuali.kra.protocol.auth.ProtocolAuthorizer#isAuthorized(java.lang.String, org.kuali.kra.protocol.auth.ProtocolTask) *//*from www. j a v a 2 s . com*/ public boolean isAuthorized(String userId, IacucProtocolOnlineReviewTask task) { boolean hasPermission = false; IacucProtocolOnlineReview protocolOnlineReview = (IacucProtocolOnlineReview) task.getProtocolOnlineReview(); ProtocolOnlineReviewDocumentBase protocolDoc = null; try { protocolDoc = (ProtocolOnlineReviewDocumentBase) KraServiceLocator.getService(DocumentService.class) .getByDocumentHeaderId( protocolOnlineReview.getProtocolOnlineReviewDocument().getDocumentNumber()); if (protocolOnlineReview.getProtocolOnlineReviewId() != null && !protocolOnlineReview.getProtocolOnlineReviewDocument().isViewOnly()) { if (hasPermission(userId, protocolOnlineReview, PermissionConstants.MAINTAIN_IACUC_ONLINE_REVIEWS) && !protocolDoc.getDocumentHeader().getWorkflowDocument().isFinal()) { hasPermission = true; } else { boolean beforeDueDate = true; if (protocolOnlineReview.getDeterminationReviewDateDue() != null) { Calendar today = Calendar.getInstance(); Calendar typeDueDate = Calendar.getInstance(); typeDueDate.setTime(protocolOnlineReview.getDeterminationReviewDateDue()); beforeDueDate = typeDueDate.after(today); } hasPermission = beforeDueDate && hasPermission(userId, protocolOnlineReview, PermissionConstants.MAINTAIN_IACUC_PROTOCOL_ONLINE_REVIEW_COMMENTS) && kraWorkflowService.isUserApprovalRequested(protocolDoc, userId); } } } catch (WorkflowException e) { LOG.error(String.format("Could not find ProtocolOnlineReviewBase, document number %s", protocolOnlineReview.getProtocolOnlineReviewDocument().getDocumentNumber())); } return hasPermission; }
From source file:py.una.pol.karaku.replication.client.ReplicationLogic.java
/** * @return/*from ww w.j a v a 2s. c o m*/ */ @Override @Transactional public Set<ReplicationInfo> getReplicationsToDo() { List<ReplicationInfo> loaded = dao.getAll(getBaseWhere(), getSearchParam()); if (loaded == null) { return Collections.emptySet(); } Set<ReplicationInfo> toRet = new HashSet<ReplicationInfo>(loaded.size()); for (ReplicationInfo ri : loaded) { Calendar now = dateProvider.getNowCalendar(); if (now.after(getNextSync(ri))) { toRet.add(loadClass(ri)); } } return toRet; }
From source file:org.bwgz.swim.openlane.service.EventServiceImpl.java
private long calculateAge(Date meetAgeDate, Date dateOfBirth) { Calendar mad = Calendar.getInstance(); Calendar dob = Calendar.getInstance(); mad.setTime(meetAgeDate);/*from w w w.jav a 2 s. co m*/ dob.setTime(dateOfBirth); if (dob.after(mad)) { throw new IllegalArgumentException("Can't be born in the future"); } int age = mad.get(Calendar.YEAR) - dob.get(Calendar.YEAR); if (mad.get(Calendar.DAY_OF_YEAR) < dob.get(Calendar.DAY_OF_YEAR)) { age--; } return age; }
From source file:com.adobe.acs.commons.reports.models.PageReplicationStatusModel.java
public String getReplicationStatus() { Session session = resource.getResourceResolver().adaptTo(Session.class); String path = resource.getPath(); if (path.contains(JcrConstants.JCR_CONTENT)) { path = StringUtils.substringAfter(path, JcrConstants.JCR_CONTENT) + JcrConstants.JCR_CONTENT; } else {/*from www .j a v a 2 s. c o m*/ path += "/" + JcrConstants.JCR_CONTENT; } log.debug("Getting replication status for {}", path); ReplicationStatus status = replicator.getReplicationStatus(session, path); Status rStatus = Status.NOT_ACTIVATED; if (status != null) { if (status.isDeactivated()) { rStatus = Status.DEACTIVATED; } else if (status.isPending()) { rStatus = Status.IN_PROGRESS; } else if (status.isActivated()) { Calendar lastModified = getLastModified(resource.getResourceResolver(), path); if (lastModified != null && status.getLastPublished() != null && lastModified.after(status.getLastPublished())) { rStatus = Status.MODIFIED; } else { rStatus = Status.ACTIVATED; } } } log.debug("Retrieved replication status {}", rStatus); return rStatus.toString(); }
From source file:br.com.transport.report.ManagerReportBean.java
/** * Retira da lista de dias da semana os dias utilizados no frete * @param mapReport//w w w. ja v a 2s. c o m * @param handlerList */ private void removeDays(Map<Long, List<Calendar>> mapReport, List<ReportVO> handlerList) { Calendar init = getInitCalendar(); Calendar end = getInitCalendar(); for (ReportVO report : handlerList) { List<Calendar> daysList = new LinkedList<Calendar>(mapReport.get(report.getCarrierId())); init.setTime(report.getDepartureDate()); end.setTime(report.getDeliveryDate()); for (Calendar cld : daysList) { if (cld.compareTo(init) == 0 || (cld.after(init) && (cld.before(end) || cld.compareTo(end) == 0))) { mapReport.get(report.getCarrierId()).remove(cld); } } } }
From source file:com.leclercb.commons.api.license.License.java
protected void validateExpiration(Calendar currentDate) throws LicenseExpiredException { CheckUtils.isNotNull(currentDate);//from w w w . j av a2 s. c om if (this.getExpiration() != null && currentDate.after(this.getExpiration())) { throw new LicenseExpiredException(); } }