List of usage examples for java.util Date after
public boolean after(Date when)
From source file:ru.apertum.qsystem.reports.formirovators.RatioServices.java
@Override public String validate(String driverClassName, String url, String username, String password, HttpRequest request, HashMap<String, String> params) { //sd=20.01.2009&ed=28.01.2009 // ? /* w w w . j a v a2s .co m*/ QLog.l().logger().trace("? \"" + params.toString() + "\"."); if (params.size() == 2) { Date sd; Date fd; Date fd1; try { sd = Uses.format_dd_MM_yyyy.parse(params.get("sd")); fd = Uses.format_dd_MM_yyyy.parse(params.get("ed")); fd1 = DateUtils.addDays(Uses.format_dd_MM_yyyy.parse(params.get("ed")), 1); } catch (ParseException ex) { return "<br> ! ? ? (..)."; } if (!sd.after(fd)) { paramMap.put("sd", sd); paramMap.put("ed", fd); paramMap.put("ed1", fd1); } else { return "<br> ! ?."; } } else { return "<br> !"; } return null;// ? }
From source file:com.virtusa.akura.reporting.controller.StudentSpecialEventAttendanceReportController.java
/** * This method is used to get list of StudentSpecialEventAttendanceTemplate to show data in report. * * @param specialEvents selected special event object * @param studSpecEventAttendeTempl list of integers * @param map to hold data to show in report * @return list of StudentSpecialEventAttendanceTemplate * @throws AkuraAppException throws when exception occur *//*w ww.j av a2 s . co m*/ private List<StudentSpecialEventAttendanceTemplate> processStudentList(SpecialEvents specialEvents, StudentSpecialEventAttendanceTemplate studSpecEventAttendeTempl, Map<String, Object> map) throws AkuraAppException { List<StudentSpecialEventParticipationView> allocatedStudents = studentService .getAllocatedStudentListForEvent( studSpecEventAttendeTempl.getSpecialEventsParticipation().getSpecialEventsParticipationId(), specialEvents.getDate()); List<Integer> studentIdList = specialEventAttendanceService.getStudentsIDOfSpecialEventAttendance( studSpecEventAttendeTempl.getSpecialEventsParticipation().getSpecialEventsParticipationId()); List<StudentSpecialEventAttendanceTemplate> templateObjlist = new ArrayList<StudentSpecialEventAttendanceTemplate>(); int totalStudents = 0; int presentStudents = 0; for (StudentSpecialEventParticipationView student : allocatedStudents) { totalStudents++; Student studentt = studentService.findStudent(student.getStudentId()); Date departureDate = studentt.getDateOfDeparture(); Date specialEventDate = specialEvents.getDate(); if (departureDate == null || departureDate != null && departureDate.after(specialEventDate)) { StudentSpecialEventAttendanceTemplate studEventAttendanceTempl = new StudentSpecialEventAttendanceTemplate(); studEventAttendanceTempl.setStudentAdmissionNo(student.getId().getAdmissionNo()); studEventAttendanceTempl.setStudentName(student.getNameWithInitals()); if (studentIdList.contains(student.getStudentId())) { presentStudents++; studEventAttendanceTempl.setAttendance(PRESENT); } else { studEventAttendanceTempl.setAttendance(AB); } templateObjlist.add(studEventAttendanceTempl); } } map.put(TOTAL_NO_OF_STUDENTS, Integer.toString(totalStudents)); map.put(NO_OF_PRESENT_STUDENTS, Integer.toString(presentStudents)); return SortUtil.sortStudentSpecialEventsAttendanceList(templateObjlist); }
From source file:org.jasig.portlet.announcements.mvc.servlet.AjaxApproveController.java
@RequestMapping public ModelAndView toggleApprove(HttpServletRequest request) throws PortletException { final Long annId = Long.valueOf(request.getParameter("annId")); final Boolean approval = Boolean.valueOf(request.getParameter("approval")); final Announcement ann = announcementService.getAnnouncement(annId); final Date startDisplay = ann.getStartDisplay(); Date endDisplay = ann.getEndDisplay(); if (endDisplay == null) { // Unspecified end date means the announcement does not expire; we // will substitute a date in the future each time this item is // evaluated. final long aYearFromNow = System.currentTimeMillis() + Announcement.MILLISECONDS_IN_A_YEAR; endDisplay = new Date(aYearFromNow); }/* w ww . java2 s . co m*/ final Date now = new Date(); int status = STATUS_PENDING; // default /* Scheduled = 0 Expired = 1 Showing = 2 Pending = 3 */ if (startDisplay.after(now) && endDisplay.after(now) && approval) { status = STATUS_SCHEDULED; } else if (startDisplay.before(now) && endDisplay.after(now) && approval) { status = STATUS_SHOWING; } else if (endDisplay.before(now)) { status = STATUS_EXPIRED; } ann.setPublished(approval); announcementService.addOrSaveAnnouncement(ann); return new ModelAndView("ajaxApprove", "status", status); }
From source file:controller.ClientController.java
@RequestMapping("/annuler") public String annulercontratAction(HttpServletRequest request, HttpSession session) throws ParseException { //ClientConnecte cli = new ClientConnecte((Client) session.getAttribute("UserConnected")); //session.removeAttribute("UserConnected"); SimpleDateFormat sdf = new SimpleDateFormat("yy-MM-dd"); int idvideo = Integer.parseInt(request.getParameter("idvideo")); Video vid = vidBDD.VideoPrec(idvideo).get(0); //System.out.println(""+datedebut); //System.out.println("Con De type Date:"+ddebut); Date currentDate = new Date(); String datecourante = sdf.format(currentDate); Date dcourante = sdf.parse(datecourante); //System.out.println(""+datecourante); //System.out.println("Cu De type Date:"+dcourante); //Raccourci la date de validation du contrat la date courante if (dcourante.after(vid.getDateDebut()) || dcourante.equals(vid.getDateDebut())) { //System.out.println("Date courant sup ou egale celle du cntrat"); vid.setDateFin(dcourante);/*from w w w . j a v a2s. c o m*/ this.vidBDD.updComContrat(vid, "annuler"); } else { //supprime le contrat si il n'est pas commenc //System.out.println("Date courant inf celle du cntrat"); vidBDD.deleteComContrat(idvideo); } return "redirect:/client"; }
From source file:edu.cmu.cs.lti.discoursedb.io.mturk.converter.MturkConverterService.java
/** * Maps a discussion forum message to DiscourseDB * // w ww .jav a 2 s. c o m * @param when * @param author * @param group * @param team * @param text * @param discourse_name * @param dataset_name * @param source_file_name * @param source_column_name * @param source_unique_index * * @returns the contribution Id written to the database */ public Long mapChat(String when, String author, String group, String team, String text, String discourse_name, String dataset_name, String source_file_name, String source_column_name, String source_unique_index) { if (when == null) { when = sdf.format(dummyTime); dummyTime = DateUtils.addMinutes(dummyTime, 1); } Discourse curDiscourse = discourseService.createOrGetDiscourse(discourse_name); User curUser = userService.createOrGetUser(curDiscourse, author); ContributionTypes mappedType = null; log.trace("Create Content entity"); Content curContent = contentService.createContent(); curContent.setText(text); curContent.setAuthor(curUser); dataSourceService.addSource(curContent, new DataSourceInstance(source_unique_index, source_file_name + "#" + source_column_name + "(content)", DataSourceTypes.BAZAAR, dataset_name)); log.trace("Create Contribution entity"); Contribution curContribution = contributionService.createTypedContribution(ContributionTypes.POST); curContribution.setCurrentRevision(curContent); curContribution.setFirstRevision(curContent); dataSourceService.addSource(curContribution, new DataSourceInstance(source_unique_index, source_file_name + "#" + source_column_name + "(contribution)", DataSourceTypes.BAZAAR, dataset_name)); discussion_source2ddb.put(Long.valueOf(source_unique_index), curContribution.getId()); DiscoursePart team_chat = discoursepartService.createOrGetDiscoursePartByDataSource(curDiscourse, group + "_" + team, "xustudty#teamchat", DataSourceTypes.BAZAAR, dataset_name, DiscoursePartTypes.CHATROOM); team_chat.setName("Team " + group + "_" + team + " chat"); DiscoursePart team_dp = discoursepartService.createOrGetTypedDiscoursePart(curDiscourse, teamDpName(group, team), DiscoursePartTypes.TEAM); discoursepartService.createDiscoursePartRelation(team_dp, team_chat, DiscoursePartRelationTypes.SUBPART); discoursepartService.addContributionToDiscoursePart(curContribution, team_chat); //parse and set creation time for content and contribution try { Date date = forgiving_date_parse(when); curContent.setStartTime(date); curContent.setEndTime(date); curContribution.setStartTime(date); curContribution.setEndTime(date); if (team_chat.getEndTime() == null || date.after(team_chat.getEndTime())) { team_chat.setEndTime(date); } if (team_chat.getStartTime() == null || date.before(team_chat.getStartTime())) { team_chat.setStartTime(date); } } catch (ParseException e) { log.error("Could not parse creation time " + when, e); } return curContribution.getId(); }
From source file:com.startup.musicstore.services.Impl.CreditCardServiceImpl.java
@Override public String processPayment(String number, BigDecimal amount, Date expiryDate) { //Search Credit card By creditNumber property on The Entity to Find if it is in the System CreditCard creditCard = getCreditCardByNumber(number); //Test if we have a credit card. // If Not Jump to the Last ELSE and throw CC Rejection Exception --Wrong Number if (creditCard != null) { // If we have a Card Check For sufficient Funds //If Less Funds Throw Exception ELSE APPROVE if (amount.doubleValue() > creditCard.getBalance().doubleValue()) { throw new CreditCardRejectionException("Insufficient Funds In the Account"); } else if (expiryDate.after(creditCard.getExpiryDate())) { //IF expiry Date is Before Credit card EXPIRY DATE Throw Exception throw new CreditCardRejectionException("Sorry Credit Date Expired"); } else {/*from ww w .java 2s .co m*/ return "APPROVED"; } } else { throw new CreditCardRejectionException("Credit Number is Wrong"); } }
From source file:com.jaspersoft.jasperserver.api.engine.jasperreports.service.impl.StandardDataCacheProvider.java
public DataSnapshotPersistentMetadata loadSavedDataSnapshot(ExecutionContext context, ReportUnit reportUnit) { Long snapshotId = reportUnit.getDataSnapshotId(); if (snapshotId == null) { return null; }/* w w w . ja va 2 s .c o m*/ if (!dataSnapshotService.isSnapshotPersistenceEnabled()) { // if snapshot persistence is disabled, don't use saved snapshots if (log.isDebugEnabled()) { log.debug("snapshot persistence is disabled, not using snapshot " + snapshotId + " for report " + reportUnit.getURIString()); } return null; } // try to load the persistent snapshot if (log.isDebugEnabled()) { log.debug("loading saved data snapshot " + snapshotId + " for " + reportUnit.getURIString()); } DataSnapshotPersistentMetadata persistentSnapshot = dataSnapshotService.getSnapshotMetadata(context, snapshotId); if (persistentSnapshot == null) { if (log.isDebugEnabled()) { log.debug("data snapshot " + snapshotId + " not found for " + reportUnit.getURIString()); } return null; } Date snapshotDate = persistentSnapshot.getSnapshotMetadata().getSnapshotDate(); Resource dataSource = getReportLoadingService().getFinalResource(context, reportUnit.getDataSource(), Resource.class); Date dataSourceTimestamp = dataSource == null ? null : dataSource.getUpdateDate(); if (dataSourceTimestamp != null && !snapshotDate.after(dataSourceTimestamp)) { // snapshot is older than data source, considering invalid if (log.isDebugEnabled()) { log.debug("data snapshot " + snapshotId + " of " + reportUnit.getURIString() + " is older (" + snapshotDate + ") than data source (" + dataSourceTimestamp + ")"); } return null; } return persistentSnapshot; }
From source file:com.mediaworx.intellij.opencmsplugin.sync.SyncFileAnalyzer.java
private void handleExistingFile(OpenCmsModule ocmsModule, File file, CmisObject vfsObject, String vfsPath) { LOG.info("It's a file that exists on the VFS and the RFS"); if (pullAllMetaInformation) { syncList.add(new SyncFile(ocmsModule, vfsPath, file, vfsObject, SyncAction.PULL, true)); } else {// w w w . j a va 2s . c o m Date localDate = new Date(file.lastModified()); Date vfsDate = vfsObject.getLastModificationDate().getTime(); if (ocmsModule.getSyncMode() == SyncMode.SYNC) { LOG.info("SyncMode is SYNC, so compare dates"); if (localDate.after(vfsDate)) { LOG.info("RFS file is newer, PUSH"); syncList.add(new SyncFile(ocmsModule, vfsPath, file, vfsObject, SyncAction.PUSH, true)); } else if (vfsDate.after(localDate)) { LOG.info("VFS file is newer, PULL"); syncList.add(new SyncFile(ocmsModule, vfsPath, file, vfsObject, SyncAction.PULL, true)); } else { LOG.info("VFS file and RFS file have the same date, ignore"); } } // if the dates are different, add the resource with PUSH or PULL action, depending on the module's syncMode else if (vfsDate.compareTo(localDate) != 0) { SyncAction syncAction = ocmsModule.getSyncMode() == SyncMode.PUSH ? SyncAction.PUSH : SyncAction.PULL; LOG.info("SyncMode is " + ocmsModule.getSyncMode() + " and files are not equal, so force " + syncAction); syncList.add(new SyncFile(ocmsModule, vfsPath, file, vfsObject, syncAction, true)); } } }
From source file:dk.dma.msinm.service.AreaService.java
/** * Potentially, a heavy-duty function that scans the entire area tree, * sorts it and update the treeSortOrder. Use with care. *//* w w w. j av a 2 s . c o m*/ public void recomputeTreeSortOrder() { long t0 = System.currentTimeMillis(); // Compare the last area update date and the last processed date Date lastAreaUpdate = getLastUpdated(); if (lastAreaUpdate == null) { // No areas return; } Date lastProcessedUpdate = settings.getDate(AREA_LAST_UPDATE); if (!lastAreaUpdate.after(lastProcessedUpdate)) { log.debug("No area tree changes since last execution of recomputeTreeSortOrder()"); return; } List<Area> roots = em.createNamedQuery("Area.findRootAreas", Area.class).getResultList(); // Sort the roots by sortOrder Collections.sort(roots); // Re-compute the tree sort order List<Area> updated = new ArrayList<>(); recomputeTreeSortOrder(roots, 0, updated, false); // Persist changed areas updated.forEach(this::saveEntity); em.flush(); // Update the last processed date settings.updateSetting(new SettingsEntity(AREA_LAST_UPDATE.getSettingName(), String.valueOf(System.currentTimeMillis() + 1000))); log.info("Recomputed tree sort order in " + (System.currentTimeMillis() - t0) + " ms"); }
From source file:net.chaosserver.timelord.data.TimelordTask.java
/** * Adds a new task day object into the proper location in the list. * * @param timelordTaskDay the day to add *///from w w w. j a v a2 s. c o m public synchronized void addTaskDay(TimelordTaskDay timelordTaskDay) { Date newTaskDate = timelordTaskDay.getDate(); boolean added = false; for (int i = 0; i < taskDayList.size(); i++) { TimelordTaskDay tempTimelordTaskDay = (TimelordTaskDay) taskDayList.get(i); if (newTaskDate.after(tempTimelordTaskDay.getDate())) { taskDayList.add(i, timelordTaskDay); added = true; break; } } if (!added) { taskDayList.addLast(timelordTaskDay); } propertyChangeSupport.firePropertyChange("taskDayList", null, taskDayList); }