List of usage examples for org.joda.time LocalDate toString
@ToString
public String toString()
From source file:at.jclehner.rxdroid.preferences.DatePreference.java
License:Open Source License
@Override protected String toPersistedString(LocalDate value) { return value.toString(); }
From source file:au.edu.uws.eresearch.cr8it.TransformationHandler.java
License:Apache License
private String getJsonMapping(String jsonString) throws IOException, ParseException { String template = readFile("./template.json"); JSONParser parser = new JSONParser(); JSONObject original = (JSONObject) parser.parse(template); JSONObject manifest = (JSONObject) parser.parse(jsonString); JSONObject dataObject = (JSONObject) original.get("data"); JSONArray dataArray = (JSONArray) dataObject.get("data"); JSONArray creators = (JSONArray) manifest.get("creators"); JSONArray activities = (JSONArray) manifest.get("activities"); JSONArray vfs = (JSONArray) manifest.get("vfs"); LocalDate today = new LocalDate(); int creatorIndex = 1; int grantIndex = 1; for (Object data : dataArray) { ((JSONObject) data).put("datasetId", jsonString.hashCode()); JSONObject tfpackage = (JSONObject) ((JSONObject) data).get("tfpackage"); tfpackage.put("dc:created", today.toString()); Object root = vfs.get(0); if (root != null) { String crateName = (String) ((JSONObject) root).get("name"); tfpackage.put("dc:title", crateName); tfpackage.put("title", crateName); }/*from w w w . j av a 2 s . co m*/ for (Object creator : creators) { //TODO we might need to split the name into first and last name String name = (String) ((JSONObject) creator).get("name"); tfpackage.put("dc:creator.foaf:Person." + creatorIndex + ".foaf:name", name); String identifier = (String) ((JSONObject) creator).get("identifier"); tfpackage.put("dc:creator.foaf:Person." + creatorIndex + ".dc:identifier", identifier); creatorIndex++; } for (Object activity : activities) { String identifier = (String) ((JSONObject) activity).get("identifier"); tfpackage.put("foaf:fundedBy.vivo:Grant." + grantIndex + ".dc:identifier", identifier); String grantNumber = (String) ((JSONObject) activity).get("grant_number"); tfpackage.put("foaf:fundedBy.vivo:Grant." + grantIndex + ".redbox:grantNumber", grantNumber); String title = (String) ((JSONObject) activity).get("title"); String repositoryName = (String) ((JSONObject) activity).get("repository_name"); tfpackage.put("foaf:fundedBy.vivo:Grant." + grantIndex + ".skos:prefLabel", "(" + repositoryName + ") " + title); grantIndex++; } } String updatedJson = original.toJSONString(); return updatedJson; }
From source file:br.com.tecsinapse.exporter.test.FakePojo2.java
License:LGPL
String toString(LocalDate data) { return data != null ? data.toString() : null; }
From source file:br.edu.unirio.pm.dao.VendasDAO.java
public List<Venda> obterVendasDoMes(MesEscolhido mesEscolhido, Vendedor vendedor) throws SQLException { comando = null;//from w w w. ja v a 2 s . c o m List<Venda> listaVendasDoMes = new ArrayList<>(); try { consulta = SELECT_MES_ESPECIFICO; ProdutosDAO produtosDAO = new ProdutosDAO(); // VendedoresDAO vendedoresDAO = new VendedoresDAO(); FabricaConexao.iniciarConexao(); comando = FabricaConexao.criarComando(consulta); LocalDate dataInicialDoMes = new LocalDate(mesEscolhido.getAno(), mesEscolhido.getMes(), 1); LocalDate dataFinalDoMes = new LocalDate(mesEscolhido.getAno(), mesEscolhido.getMes(), mesEscolhido.obterQuantidadeDeDiasDoMes()); // System.out.println("DATA INICIAL " + dataInicialDoMes); // System.out.println("DATA FINAL " + dataFinalDoMes); comando.setDate(1, Date.valueOf(dataInicialDoMes.toString())); comando.setDate(2, Date.valueOf(dataFinalDoMes.toString())); comando.setLong(3, vendedor.getCodigo()); resultado = comando.executeQuery(); while (resultado.next()) { Venda venda = new Venda(); venda.setDataVenda(new LocalDate(resultado.getDate("DATA_VENDA"))); venda.setProduto(produtosDAO.buscarProdutoNoBanco(resultado.getLong("COD_PRODUTO"))); venda.setQuantidadeVendida(resultado.getInt("QUANTIDADE")); venda.setVendedor(vendedor); // venda.setVendedor(vendedoresDAO.buscarVendedorNoBanco(resultado. // getLong("COD_VENDEDOR"))); // if (vendaPertenceAListaVendasDoMes(venda)) listaVendasDoMes.add(venda); } // imprimeListaDoMes(listaVendasDoMes); //IMPRIME return listaVendasDoMes; } finally { FabricaConexao.fecharComando(comando); FabricaConexao.fecharConexao(); } }
From source file:ca.ualberta.physics.cssdp.util.JSONLocalDateSerializer.java
License:Apache License
@Override public void serialize(LocalDate value, JsonGenerator jgen, SerializerProvider provider) throws IOException, JsonProcessingException { jgen.writeString(value.toString()); }
From source file:ch.ralscha.extdirectspring.provider.RemoteProviderTreeLoad.java
License:Apache License
@ExtDirectMethod(value = ExtDirectMethodType.TREE_LOAD, entryClass = String.class) public List<Node> method2(@RequestParam("node") String node, @RequestParam(defaultValue = "defaultValue") String foo, @DateTimeFormat(iso = ISO.DATE) LocalDate today) { return createTreeList(node, ":" + foo + ";" + today.toString()); }
From source file:com.actimem.blog.jaxb.adapters.LocalDateAdapter.java
License:Apache License
@Override public String marshal(LocalDate v) throws Exception { return v.toString(); }
From source file:com.allogy.json.jackson.joda.ISOLocalDateSerializer.java
License:Apache License
@Override public void serialize(LocalDate localDate, JsonGenerator jsonGenerator, SerializerProvider serializerProvider) throws IOException, JsonProcessingException { String isoFormat = localDate.toString(); if (isoFormat == null || isoFormat.isEmpty()) return;// ww w . j av a2s.c o m jsonGenerator.writeString(isoFormat); }
From source file:com.axelor.apps.account.service.debtrecovery.DoubtfulCustomerService.java
License:Open Source License
/** * Fonction permettant de rcuprer les critures de facture transfrer sur le compte client douteux * @param rule//w w w. j a v a2s . c o m * Le rgle appliquer : * <ul> * <li>0 = Crance de + 6 mois</li> * <li>1 = Crance de + 3 mois</li> * </ul> * @param doubtfulCustomerAccount * Le compte client douteux * @param company * La socit * @return * Les critures de facture transfrer sur le compte client douteux */ public List<Move> getMove(int rule, Account doubtfulCustomerAccount, Company company) { LocalDate date = null; switch (rule) { //Crance de + 6 mois case 0: date = this.today.minusMonths(company.getAccountConfig().getSixMonthDebtMonthNumber()); break; //Crance de + 3 mois case 1: date = this.today.minusMonths(company.getAccountConfig().getThreeMonthDebtMontsNumber()); break; default: break; } log.debug("Date de crance prise en compte : {} ", date); String request = "SELECT DISTINCT m FROM MoveLine ml, Move m WHERE ml.move = m AND ml.company.id = " + company.getId() + " AND ml.account.reconcileOk = 'true' " + "AND ml.invoice IS NOT NULL AND ml.amountRemaining > 0.00 AND ml.debit > 0.00 AND ml.dueDate < '" + date.toString() + "' AND ml.account.id != " + doubtfulCustomerAccount.getId(); log.debug("Requete : {} ", request); Query query = JPA.em().createQuery(request); @SuppressWarnings("unchecked") List<Move> moveList = query.getResultList(); return moveList; }
From source file:com.axelor.apps.account.service.MoveLineExportService.java
License:Open Source License
/** * Mthode ralisant l'export SI - Agresso des fichiers dtails * @param mlr/* w ww . ja va2s.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 (AnalyticDistributionLine analyticDistributionLine : moveLine3 .getAnalyticDistributionLineList()) { analyticAccounts = analyticAccounts + analyticDistributionLine.getAnalyticAccount().getCode() + "/"; } if (typeSelect == 9) { items[7] = ""; items[8] = analyticAccounts; items[9] = String.format("%s DU %s", journal.getCode(), date.toString("dd/MM/yyyy")); } else { items[7] = analyticAccounts; items[8] = String.format("%s DU %s", journal.getCode(), date.toString("dd/MM/yyyy")); } 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); }