List of usage examples for java.time LocalDate toString
@Override
public String toString()
From source file:OrderDAOTests.java
@Before public void setup() { ApplicationContext ctx = new ClassPathXmlApplicationContext("applicationContext.xml"); orderDAOTests = (OrderDAO) ctx.getBean("orderTest"); LocalDate currentDate = LocalDate.now(); currentDateString = currentDate.toString(); // Add 50 orders for setup for (int i = 1; i <= 50; i++) { Order testOrder = new Order(); testOrder.setCustomerName("Customer" + i); testOrder.setCustomerState("OH"); testOrder.setTaxRate(6.5);//from w w w. j a va 2s . c om testOrder.setTotalCost(50.00 + i); testOrder.setOrderID(orderDAOTests.assignID(currentDateString)); orderDAOTests.addOrder(currentDateString, testOrder); } // Add one different order to test search functionality Order testOrder = new Order(); testOrder.setCustomerName("Larry"); testOrder.setCustomerState("MI"); testOrder.setTaxRate(6.5); testOrder.setTotalCost(50.00); testOrder.setOrderID(orderDAOTests.assignID(currentDateString)); orderDAOTests.addOrder(currentDateString, testOrder); }
From source file:org.jgrades.lic.app.utils.LicenceBuilder.java
public LicenceBuilder withEndOfValid(LocalDate toDateTime) { if (Optional.ofNullable(toDateTime).isPresent() && !StringUtils.isEmpty(toDateTime.toString())) { product.setValidTo(LocalDateTime.of(toDateTime, LocalTime.of(0, 0))); }/*from w ww .ja v a 2s . c o m*/ return this; }
From source file:org.jgrades.lic.app.utils.LicenceBuilder.java
public LicenceBuilder withStartOfValid(LocalDate fromDateTime) { if (Optional.ofNullable(fromDateTime).isPresent() && !StringUtils.isEmpty(fromDateTime.toString())) { product.setValidFrom(LocalDateTime.of(fromDateTime, LocalTime.of(0, 0))); }/*from w w w . ja v a 2s. c o m*/ return this; }
From source file:com.geometrycloud.happydonut.ui.ChartFilterPanel.java
/** * Carga la informacion para generar la grafica con el top de ventas. * * @param from desde donde buscar.// ww w . j a v a 2s .c o m * @param to hasta donde buscar. * @return informacion de la grafica. */ private PieDataset chartDataset(LocalDate from, LocalDate to) { DefaultPieDataset dataset = new DefaultPieDataset(); RowList sales = DATABASE.table(SALES_TABLE_NAME).where(SALES_SALE_DATE, ">=", from.toString()) .where(SALES_SALE_DATE, "<=", to.toString()).get(SALES_PRIMARY_KEY, SALES_SALE_DATE); HashMap<String, Long> top = new HashMap<>(); for (Row sale : sales) { RowList details = DATABASE.table(SALE_DETAILS_TABLE_NAME) .where(SALE_DETAILS_SALE, "=", sale.value(SALES_PRIMARY_KEY)) .get(SALE_DETAILS_NAME, SALE_DETAILS_QUANTITY); String name; Long quantity; for (Row detail : details) { name = detail.string(SALE_DETAILS_NAME); quantity = detail.number(SALE_DETAILS_QUANTITY); if (top.containsKey(name)) { quantity += top.get(name); } top.put(name, quantity); } } top.forEach((k, v) -> dataset.setValue(k, v)); return dataset; }
From source file:com.gigglinggnus.controllers.ManageExamsController.java
@Override protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { EntityManager em = (EntityManager) request.getSession().getAttribute("em"); Clock clk = (Clock) (request.getSession().getAttribute("clock")); List<Term> terms = Term.getFutureTerms(em, Instant.now(clk)); List<Exam> exams = terms.stream().flatMap(term -> term.getExams().stream()) .filter(exam -> exam.getStatus() == ExamStatus.PENDING).collect(Collectors.toList()); Map<Exam, ArrayList<String>> utilMap = new HashMap(); for (Exam e : exams) { Interval<Instant> examInt = e.getInterval(); LocalDate testDate = examInt.getStart().atZone(ZoneId.systemDefault()).toLocalDate(); LocalDate endDate = examInt.getEnd().atZone(ZoneId.systemDefault()).toLocalDate(); Term t = e.getTerm();//from w w w. j ava2s . c om Map<LocalDate, Long> examUtilMap = new HashMap(); ArrayList<String> examList = new ArrayList(); while (testDate.isBefore(endDate.plusDays(1))) { examList.add(testDate.toString() + "=" + t.utilizationForDay(testDate, clk) + " "); testDate = testDate.plusDays(1); } utilMap.put(e, examList); } request.setAttribute("exams", exams); request.setAttribute("utilList", utilMap); RequestDispatcher rd = request.getRequestDispatcher("/admin/manage-exams.jsp"); rd.forward(request, response); }
From source file:org.ojbc.connectors.warrantmod.InitiateWarrantModificationRequestProcessor.java
private void appendNcDate(Element parentElement, LocalDate localDate) { Element dateElement = XmlUtils.appendElement(parentElement, NS_NC_30, "Date"); dateElement.setTextContent(localDate.toString()); }
From source file:com.hotelbeds.distribution.hotel_api_sdk.HotelApiClient.java
public BookingListRS list(LocalDate start, LocalDate end, int from, int to, BookingListFilterStatus status, BookingListFilterType filterType, Properties properties, List<String> countries, List<String> destinations, String clientReference, List<Integer> hotels) throws HotelApiSDKException { final Map<String, String> params = new HashMap<>(); params.put("start", start.toString()); params.put("end", end.toString()); params.put("from", Integer.toString(from)); params.put("to", Integer.toString(to)); if (status != null) { params.put("status", status.name()); }/* ww w.jav a2s .c o m*/ if (filterType != null) { params.put("filterType", filterType.name()); } if (countries != null && !countries.isEmpty()) { params.put("country", String.join(",", countries)); } if (destinations != null && !destinations.isEmpty()) { params.put("destination", String.join(",", destinations)); } if (hotels != null && !hotels.isEmpty()) { params.put("hotel", hotels.stream().map(hotelCode -> hotelCode.toString()).collect(Collectors.joining(","))); } if (clientReference != null) { params.put("clientReference", clientReference); } addPropertiesAsParams(properties, params); return (BookingListRS) callRemoteAPI(params, HotelApiPaths.BOOKING_LIST); }
From source file:com.axelor.apps.account.service.MoveLineExportService.java
/** * Mthode ralisant l'export SI - Agresso des fichiers dtails * @param mlr// w ww . j a v a2 s .c om * @param fileName * @throws AxelorException * @throws IOException */ @SuppressWarnings("unchecked") public void exportMoveLineAllTypeSelectFILE2(MoveLineReport moveLineReport, String fileName) throws AxelorException, IOException { log.info("In export service FILE 2 :"); Company company = moveLineReport.getCompany(); String companyCode = ""; String moveLineQueryStr = ""; int typeSelect = moveLineReport.getTypeSelect(); if (company != null) { companyCode = company.getCode(); moveLineQueryStr += String.format(" AND self.move.company = %s", company.getId()); } if (moveLineReport.getJournal() != null) { moveLineQueryStr += String.format(" AND self.move.journal = %s", moveLineReport.getJournal().getId()); } else { moveLineQueryStr += String.format(" AND self.move.journal.type = %s", moveLineReportService.getJournalType(moveLineReport).getId()); } if (moveLineReport.getPeriod() != null) { moveLineQueryStr += String.format(" AND self.move.period = %s", moveLineReport.getPeriod().getId()); } if (moveLineReport.getDateFrom() != null) { moveLineQueryStr += String.format(" AND self.date >= '%s'", moveLineReport.getDateFrom().toString()); } if (moveLineReport.getDateTo() != null) { moveLineQueryStr += String.format(" AND self.date <= '%s'", moveLineReport.getDateTo().toString()); } if (moveLineReport.getDate() != null) { moveLineQueryStr += String.format(" AND self.date <= '%s'", moveLineReport.getDate().toString()); } if (typeSelect != 8) { moveLineQueryStr += String.format(" AND self.account.reconcileOk = false "); } moveLineQueryStr += String.format( "AND self.move.accountingOk = true AND self.move.ignoreInAccountingOk = false AND self.move.moveLineReport = %s", moveLineReport.getId()); moveLineQueryStr += String.format(" AND self.move.statusSelect = %s ", MoveRepository.STATUS_VALIDATED); Query queryDate = JPA.em().createQuery( "SELECT self.date from MoveLine self where self.account != null AND (self.debit > 0 OR self.credit > 0) " + moveLineQueryStr + " group by self.date ORDER BY self.date"); List<LocalDate> dates = new ArrayList<LocalDate>(); dates = queryDate.getResultList(); log.debug("dates : {}", dates); List<String[]> allMoveLineData = new ArrayList<String[]>(); for (LocalDate localDate : dates) { Query queryExportAgressoRef = JPA.em().createQuery( "SELECT DISTINCT self.move.exportNumber from MoveLine self where self.account != null " + "AND (self.debit > 0 OR self.credit > 0) AND self.date = '" + localDate.toString() + "'" + moveLineQueryStr); List<String> exportAgressoRefs = new ArrayList<String>(); exportAgressoRefs = queryExportAgressoRef.getResultList(); for (String exportAgressoRef : exportAgressoRefs) { if (exportAgressoRef != null && !exportAgressoRef.isEmpty()) { int sequence = 1; Query query = JPA.em().createQuery( "SELECT self.account.id from MoveLine self where self.account != null AND (self.debit > 0 OR self.credit > 0) " + "AND self.date = '" + localDate.toString() + "' AND self.move.exportNumber = '" + exportAgressoRef + "'" + moveLineQueryStr + " group by self.account.id"); List<Long> accountIds = new ArrayList<Long>(); accountIds = query.getResultList(); log.debug("accountIds : {}", accountIds); for (Long accountId : accountIds) { if (accountId != null) { String accountCode = accountRepo.find(accountId).getCode(); List<MoveLine> moveLines = moveLineRepo.all().filter( "self.account.id = ?1 AND (self.debit > 0 OR self.credit > 0) AND self.date = '" + localDate.toString() + "' AND self.move.exportNumber = '" + exportAgressoRef + "'" + moveLineQueryStr, accountId).fetch(); log.debug("movelines : {} ", moveLines); if (moveLines.size() > 0) { List<MoveLine> moveLineList = moveLineService.consolidateMoveLines(moveLines); List<MoveLine> sortMoveLineList = this.sortMoveLineByDebitCredit(moveLineList); for (MoveLine moveLine3 : sortMoveLineList) { Journal journal = moveLine3.getMove().getJournal(); LocalDate date = moveLine3.getDate(); String items[] = null; if (typeSelect == 9) { items = new String[13]; } else { items = new String[12]; } items[0] = companyCode; items[1] = journal.getExportCode(); items[2] = moveLine3.getMove().getExportNumber(); items[3] = String.format("%s", sequence); sequence++; items[4] = accountCode; BigDecimal totAmt = moveLine3.getCredit().subtract(moveLine3.getDebit()); String moveLineSign = "C"; if (totAmt.compareTo(BigDecimal.ZERO) == -1) { moveLineSign = "D"; totAmt = totAmt.negate(); } items[5] = moveLineSign; items[6] = totAmt.toString(); String analyticAccounts = ""; for (AnalyticMoveLine analyticDistributionLine : moveLine3 .getAnalyticMoveLineList()) { analyticAccounts = analyticAccounts + analyticDistributionLine.getAnalyticAccount().getCode() + "/"; } if (typeSelect == 9) { items[7] = ""; items[8] = analyticAccounts; items[9] = String.format("%s DU %s", journal.getCode(), date.format(DATE_FORMAT)); } else { items[7] = analyticAccounts; items[8] = String.format("%s DU %s", journal.getCode(), date.format(DATE_FORMAT)); } allMoveLineData.add(items); } } } } } } } String filePath = accountConfigService.getExportPath(accountConfigService.getAccountConfig(company)); new File(filePath).mkdirs(); log.debug("Full path to export : {}{}", filePath, fileName); CsvTool.csvWriter(filePath, fileName, '|', null, allMoveLineData); // Utilis pour le debuggage // CsvTool.csvWriter(filePath, fileName, '|', this.createHeaderForDetailFile(typeSelect), allMoveLineData); }
From source file:serposcope.controllers.google.GoogleTargetController.java
public Result target(Context context, @PathParam("targetId") Integer targetId, @Param("startDate") String startDateStr, @Param("endDate") String endDateStr) { GoogleTarget target = getTarget(context, targetId); List<GoogleSearch> searches = context.getAttribute("searches", List.class); Group group = context.getAttribute("group", Group.class); Config config = baseDB.config.getConfig(); String display = context.getParameter("display", config.getDisplayGoogleTarget()); if (!Config.VALID_DISPLAY_GOOGLE_TARGET.contains(display) && !"export".equals(display)) { display = Config.DEFAULT_DISPLAY_GOOGLE_TARGET; }//www . ja va 2s. c o m if (target == null) { context.getFlashScope().error("error.invalidTarget"); return Results.redirect( router.getReverseRoute(GoogleGroupController.class, "view", "groupId", group.getId())); } Run minRun = baseDB.run.findFirst(group.getModule(), RunDB.STATUSES_DONE, null); Run maxRun = baseDB.run.findLast(group.getModule(), RunDB.STATUSES_DONE, null); if (maxRun == null || minRun == null || searches.isEmpty()) { String fallbackDisplay = "export".equals(display) ? "table" : display; return Results.ok() .template("/serposcope/views/google/GoogleTargetController/" + fallbackDisplay + ".ftl.html") .render("startDate", "").render("endDate", "").render("display", fallbackDisplay) .render("target", target); } LocalDate minDay = minRun.getDay(); LocalDate maxDay = maxRun.getDay(); LocalDate startDate = null; if (startDateStr != null) { try { startDate = LocalDate.parse(startDateStr); } catch (Exception ex) { } } LocalDate endDate = null; if (endDateStr != null) { try { endDate = LocalDate.parse(endDateStr); } catch (Exception ex) { } } if (startDate == null || endDate == null || endDate.isBefore(startDate)) { startDate = maxDay.minusDays(30); endDate = maxDay; } Run firstRun = baseDB.run.findFirst(group.getModule(), RunDB.STATUSES_DONE, startDate); Run lastRun = baseDB.run.findLast(group.getModule(), RunDB.STATUSES_DONE, endDate); List<Run> runs = baseDB.run.listDone(firstRun.getId(), lastRun.getId()); startDate = firstRun.getDay(); endDate = lastRun.getDay(); switch (display) { case "table": case "variation": return Results.ok().template("/serposcope/views/google/GoogleTargetController/" + display + ".ftl.html") .render("target", target).render("searches", searches).render("startDate", startDate.toString()) .render("endDate", endDate.toString()).render("minDate", minDay).render("maxDate", maxDay) .render("display", display); case "chart": return renderChart(group, target, searches, runs, minDay, maxDay, startDate, endDate); case "export": return renderExport(group, target, searches, runs, minDay, maxDay, startDate, endDate); default: throw new IllegalStateException(); } }
From source file:serposcope.controllers.google.GoogleTargetController.java
protected Result renderChart(Group group, GoogleTarget target, List<GoogleSearch> searches, List<Run> runs, LocalDate minDay, LocalDate maxDay, LocalDate startDate, LocalDate endDate) { String display = "chart"; StringBuilder builder = new StringBuilder("{\"searches\": ["); for (GoogleSearch search : searches) { builder.append("\"").append(StringEscapeUtils.escapeJson(search.getKeyword())).append("\","); }/*www . j a va 2 s . c om*/ builder.setCharAt(builder.length() - 1, ']'); builder.append(",\"ranks\": ["); int maxRank = 0; for (Run run : runs) { builder.append("\n\t[").append(run.getStarted().toEpochSecond(ZoneOffset.UTC) * 1000l).append(","); // calendar builder.append("null,"); Map<Integer, GoogleRank> ranks = googleDB.rank.list(run.getId(), group.getId(), target.getId()).stream() .collect(Collectors.toMap((g) -> g.googleSearchId, Function.identity())); for (GoogleSearch search : searches) { GoogleRank fullRank = ranks.get(search.getId()); // GoogleRank fullRank = googleDB.rank.getFull(run.getId(), group.getId(), target.getId(), search.getId()); if (fullRank != null && fullRank.rank != GoogleRank.UNRANKED && fullRank.rank > maxRank) { maxRank = fullRank.rank; } builder.append(fullRank == null || fullRank.rank == GoogleRank.UNRANKED ? "null" : fullRank.rank) .append(','); } builder.setCharAt(builder.length() - 1, ']'); builder.append(","); } builder.setCharAt(builder.length() - 1, ']'); builder.append(",\n\"maxRank\": ").append(maxRank).append("}"); List<Event> events = baseDB.event.list(group, startDate, endDate); String jsonEvents = null; try { jsonEvents = objectMapper.writeValueAsString(events); } catch (JsonProcessingException ex) { jsonEvents = "[]"; } Map<Integer, GoogleBest> bestRanks = new HashMap<>(); for (GoogleSearch search : searches) { bestRanks.put(search.getId(), googleDB.rank.getBest(target.getGroupId(), target.getId(), search.getId())); } return Results.ok().template("/serposcope/views/google/GoogleTargetController/" + display + ".ftl.html") .render("target", target).render("searches", searches).render("startDate", startDate.toString()) .render("endDate", endDate.toString()).render("minDate", minDay).render("maxDate", maxDay) .render("display", display).render("ranksJson", builder.toString()) .render("eventsJson", jsonEvents); }