List of usage examples for java.time LocalDate now
public static LocalDate now()
From source file:ch.algotrader.dao.TransactionDaoImpl.java
@Override public List<Transaction> findDailyTransactionsByStrategy(String strategyName) { Validate.notEmpty(strategyName, "Strategy name is empty"); LocalDate today = LocalDate.now(); return find("Transaction.findDailyTransactionsByStrategy", QueryType.BY_NAME, new NamedParam("curdate", DateTimeLegacy.toLocalDate(today)), new NamedParam("strategyName", strategyName)); }
From source file:com.realdolmen.rdfleet.scheduling.ScheduledTasks.java
/** * Will run the car renewal notification process every saturday at 2am. * When a car has reached 160.000km or when the car has been owned for 4 years, the employee should be notified he should get a new car. *///from w w w .j av a 2 s .co m // @Scheduled(cron = "0 0 2 * * SAT") @Scheduled(fixedRate = (1000 * 60 * 30)) //30 minutes for testing purposes public void checkForNeededCarRenewals() throws MessagingException { List<RdEmployee> allEmployeesInService = rdEmployeeRepository.findAllEmployeesInService(); for (RdEmployee employee : allEmployeesInService) { Order currentOrder = employee.getCurrentOrder(); if (currentOrder == null) continue; EmployeeCar orderedCar = currentOrder.getOrderedCar(); if (orderedCar == null) continue; //If the car is not being used, skip it. if (orderedCar.getCarStatus() != CarStatus.IN_USE) continue; //If the car was received longer than 4 years ago, send a notification LocalDate fourYearsAgo = LocalDate.now().minusYears(4); if (currentOrder.getDateReceived().isBefore(fourYearsAgo)) { String message = String.format("<p>Hello %s %s,</p>\n" + "<p>It's time to order a new car! You have owned your car (%s) for more than 4 years.</p>", employee.getFirstName(), employee.getLastName(), orderedCar.getLicensePlate()); sendMail(employee.getEmail(), "Time to order a new car!", message); //Continue, we sent a message. continue; } //If the car has over 160.000km, also send a notification if (orderedCar.getMileage() > 160_000) { String message = String.format("<p>Hello %s %s,</p>\n" + "<p>It's time to order a new car! Your car (%s) has driven more than 160,000km. %,dkm to be more precise.</p>", employee.getFirstName(), employee.getLastName(), orderedCar.getLicensePlate(), orderedCar.getMileage()); sendMail(employee.getEmail(), "Time to order a new car!", message); } } }
From source file:br.com.elotech.karina.service.impl.LicenseServiceImpl.java
private LocalDate getExpirationDate(IntegracaoLicenca integracaoLicenca) { if (integracaoLicenca.getQuitacaoTitulo() == null) { if (integracaoLicenca.getVencimentoTitulo() == null) { return LocalDate.now(); }/* w w w . j ava 2 s .c o m*/ return integracaoLicenca.getVencimentoTitulo().plusDays(VENCIMENTO_CARENCIA); } else { return integracaoLicenca.getQuitacaoTitulo().plusMonths(1); } }
From source file:org.silverpeas.core.index.indexing.model.RepositoryIndexer.java
public void removePath(Path path, String creatorId) { performPath(path, LocalDate.now(), creatorId, REMOVE_ACTION); }
From source file:mesclasses.view.RapportClasseController.java
public void init() { name += " for classe " + classe; rapportLabel.setText("Rapport pour la " + classe); if (trimestres != null && !trimestres.isEmpty()) { Trimestre current = model.getForDate(LocalDate.now()); smartSelect.select(current);/*from www . j av a 2s .c om*/ } }
From source file:ch.algotrader.dao.trade.OrderDaoImpl.java
@Override public List<Order> getDailyOrders() { LocalDate today = LocalDate.now(); return find("Order.findDailyOrders", QueryType.BY_NAME, new NamedParam("curdate", DateTimeLegacy.toLocalDate(today))); }
From source file:PDFBuilderTest.java
@Test public void createPDF() throws Exception { Employee employee = new Employee(); employee.setFirstName("John"); employee.setLastName("Smith"); pdfBuilder.setEmployee(employee);/*from w w w. j av a2 s . c o m*/ User issuer = new User(); issuer.setFirstName("Peter"); issuer.setLastName("Cruz"); pdfBuilder.setIssuer(issuer); Asset asset = new Asset(); DeviceBrand db = new DeviceBrand("HP"); DeviceType dt = new DeviceType("Laptop"); DeviceModel dm = new DeviceModel(dt, db, "840 G1"); asset.setDeviceModel(dm); asset.setSerialNumber("32179879"); asset.setInventoryNumber("A000402"); pdfBuilder.setAssets(Collections.singletonList(asset)); pdfBuilder.setDate(LocalDate.now()); String file = pdfBuilder.createPDF(); System.out.println("file: " + file); assertTrue(Files.exists(Paths.get(file))); }
From source file:org.sonatype.nexus.tasklog.TaskLogCleanup.java
void cleanup() { String taskLogsHome = getTaskLogHome(); if (taskLogsHome == null) { // we are forgiving if the task logs home is not defined. Just log a message with a call to action. log.warn(/*ww w . j a v a2 s . c o m*/ "Unable to cleanup task log files. Please check that the 'tasklogfile' appender exists in logback.xml"); return; } File logFilesHome = new File(taskLogsHome); log.info("Cleaning up log files in {} older than {} days", logFilesHome.getAbsolutePath(), numberOfDays); LocalDate now = LocalDate.now().minusDays(numberOfDays); Date thresholdDate = Date.from(now.atStartOfDay(ZoneId.systemDefault()).toInstant()); AgeFileFilter ageFileFilter = new AgeFileFilter(thresholdDate); Iterator<File> filesToDelete = iterateFiles(logFilesHome, ageFileFilter, ageFileFilter); filesToDelete.forEachRemaining(f -> { try { forceDelete(f); log.info("Removed task log file {}", f.toString()); } catch (IOException e) { // NOSONAR log.error("Unable to delete task file {}. Message was {}.", f.toString(), e.getMessage()); } }); }
From source file:fi.helsinki.opintoni.service.CourseService.java
public Stream<String> getTeacherCourseIds(String teacherNumber) { return oodiClient.getTeacherCourses(teacherNumber, DateTimeUtil.getSemesterStartDateString(LocalDate.now())) .stream().map(e -> String.valueOf(e.realisationId)); }
From source file:fr.lepellerin.ecole.web.controller.cantine.ReservationRepasAnneeController.java
/** * init le model de la page details des reservations. * * @param model// w w w . ja v a 2 s . c o m * : model spring * @return le nom de la vue * @throws TechnicalException */ @RequestMapping("/submit") public String reserver(final Model model, @ModelAttribute("command") ReserverRepasForm form) throws TechnicalException { final CurrentUser user = (CurrentUser) SecurityContextHolder.getContext().getAuthentication() .getPrincipal(); this.cantineService.reserver(LocalDate.now(), user.getUser().getFamille(), form.getJoursCoches()); model.addAttribute("confirm", "Les modifications ont t enregistres."); return VUE; }