List of usage examples for java.time LocalDateTime now
public static LocalDateTime now()
From source file:org.tomitribe.tribestream.registryng.service.monitoring.MailAlerter.java
private void sendMail(final Alert alert) throws MessagingException { final String subject = StrSubstitutor.replace(subjectTemplate, new HashMap<String, String>() { {/* w w w . ja v a 2 s.c om*/ put("hostname", hostname); put("date", LocalDateTime.now().toString()); } }); final String body = alert.text(); final MimeMessage message = new MimeMessage(session); message.setFrom(new InternetAddress(from)); message.addRecipient(Message.RecipientType.TO, new InternetAddress(to)); message.setSubject(subject); message.setText(body); Transport.send(message); }
From source file:org.ow2.proactive.workflow_catalog.rest.service.WorkflowRevisionService.java
@Transactional public WorkflowMetadata createWorkflowRevision(Long bucketId, Optional<Long> workflowId, ProActiveWorkflowParserResult proActiveWorkflowParserResult, Optional<String> layout, byte[] proActiveWorkflowXmlContent) { Bucket bucket = findBucket(bucketId); Workflow workflow = null;/*from ww w . j a v a2 s . c o m*/ WorkflowRevision workflowRevision; String layoutValue = layout.orElse(""); long revisionNumber = 1; if (workflowId.isPresent()) { workflow = findWorkflow(workflowId.get()); revisionNumber = workflow.getLastRevisionId() + 1; } workflowRevision = new WorkflowRevision(bucketId, revisionNumber, proActiveWorkflowParserResult.getJobName(), proActiveWorkflowParserResult.getProjectName(), LocalDateTime.now(), layoutValue, proActiveWorkflowXmlContent); workflowRevision.addGenericInformation( createEntityGenericInformation(proActiveWorkflowParserResult.getGenericInformation())); workflowRevision.addVariables(createEntityVariable(proActiveWorkflowParserResult.getVariables())); workflowRevision = workflowRevisionRepository.save(workflowRevision); if (!workflowId.isPresent()) { workflow = new Workflow(bucket, workflowRevision); } else { workflow.addRevision(workflowRevision); } workflowRepository.save(workflow); return new WorkflowMetadata(workflowRevision); }
From source file:org.deeplearning4j.patent.LocalTraining.java
/** * JCommander entry point//from w w w . j a va 2 s. c o m * * @param args * @throws Exception */ protected void entryPoint(String[] args) throws Exception { JCommanderUtils.parseArgs(this, args); File resultFile = new File(outputPath, "results.txt"); //Output will be written here Preconditions.checkArgument(convergenceEvalFrequencyBatches > 0, "convergenceEvalFrequencyBatches must be positive: got %s", convergenceEvalFrequencyBatches); Nd4j.getMemoryManager().setAutoGcWindow(15000); // Prepare neural net ComputationGraph net = new ComputationGraph(NetworkConfiguration.getConf()); net.init(); net.setListeners(new PerformanceListener(listenerFrequency, true)); log.info("Parameters: {}", net.params().length()); //Write configuration writeConfig(); // Train neural net DateTimeFormatter dtf = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); int subsetCount = 0; boolean firstSave = true; long overallStart = System.currentTimeMillis(); boolean exit = false; for (int epoch = 0; epoch < numEpochs; epoch++) { // Training log.info("epoch {} training begin: {}", epoch + 1, dtf.format(LocalDateTime.now())); // Prepare training data. Note we'll get this again for each epoch in case we are using early termination iterator // plus randomization. This is to ensure consistency between epochs DataSetIterator trainData = getDataIterator(dataDir, true, totalExamplesTrain, batchSize, rngSeed); //For convergence purposes: want to split into subsets, time training on each subset, an evaluate while (trainData.hasNext()) { subsetCount++; log.info("Starting training: epoch {} of {}, subset {} ({} minibatches)", (epoch + 1), numEpochs, subsetCount, convergenceEvalFrequencyBatches); DataSetIterator subset = new EarlyTerminationDataSetIterator(trainData, convergenceEvalFrequencyBatches); int itersBefore = net.getIterationCount(); long start = System.currentTimeMillis(); net.fit(subset); long end = System.currentTimeMillis(); int iterAfter = net.getIterationCount(); //Save model if (saveConvergenceNets) { String fileName = "net_" + System.currentTimeMillis() + "_epoch" + epoch + "_subset" + subsetCount + ".zip"; String outpath = FilenameUtils.concat(outputPath, "nets/" + fileName); File f = new File(outpath); if (firstSave) { firstSave = false; f.getParentFile().mkdirs(); } ModelSerializer.writeModel(net, f, true); log.info("Saved network to {}", outpath); } DataSetIterator test = getDataIterator(dataDir, false, totalExamplesTrain, batchSize, rngSeed); long startEval = System.currentTimeMillis(); IEvaluation[] evals = net.doEvaluation(test, new Evaluation(), new ROCMultiClass()); long endEval = System.currentTimeMillis(); StringBuilder sb = new StringBuilder(); Evaluation e = (Evaluation) evals[0]; ROCMultiClass r = (ROCMultiClass) evals[1]; sb.append("epoch ").append(epoch + 1).append(" of ").append(numEpochs).append(" subset ") .append(subsetCount).append(" subsetMiniBatches ").append(iterAfter - itersBefore) //Note: "end of epoch" effect - may be smaller than subset size .append(" trainMS ").append(end - start).append(" evalMS ").append(endEval - startEval) .append(" accuracy ").append(e.accuracy()).append(" f1 ").append(e.f1()).append(" AvgAUC ") .append(r.calculateAverageAUC()).append(" AvgAUPRC ").append(r.calculateAverageAUCPR()) .append("\n"); FileUtils.writeStringToFile(resultFile, sb.toString(), Charset.forName("UTF-8"), true); //Append new output to file saveEvaluation(false, evals); log.info("Evaluation: {}", sb.toString()); if (maxTrainingTimeMin > 0 && (System.currentTimeMillis() - overallStart) / 60000 > maxTrainingTimeMin) { log.info("Exceeded max training time of {} minutes - terminating", maxTrainingTimeMin); exit = true; break; } } if (exit) break; } File dir = new File(outputPath, "trainedModel.bin"); net.save(dir, true); }
From source file:de.sainth.recipe.backend.security.AuthFilter.java
private Cookie createCookie(RecipeManagerAuthenticationToken authentication, boolean secure) { String newToken = Jwts.builder() // .compressWith(new GzipCompressionCodec()) .setSubject(authentication.getPrincipal().toString()) .setExpiration(/*w ww.ja v a 2 s.c o m*/ Date.from(LocalDateTime.now().plusMinutes(30).atZone(ZoneId.systemDefault()).toInstant())) .claim(TOKEN_ROLE, authentication.getAuthorities().get(0).getAuthority()).setIssuedAt(new Date()) .signWith(SignatureAlgorithm.HS256, key).compact(); Cookie cookie = new Cookie(COOKIE_NAME, newToken); cookie.setSecure(secure); cookie.setHttpOnly(true); cookie.setMaxAge(30 * 60); return cookie; }
From source file:com.gnadenheimer.mg3.controller.admin.AdminConfigController.java
@FXML private void cmdPrintFactura(ActionEvent event) { try {/* w ww . j a v a 2 s.c om*/ TblFacturas testF = new TblFacturas(); testF.setNro(1234567); testF.setFechahora(LocalDateTime.now()); testF.setRazonSocial("Empresa SA"); testF.setRuc("8888888-9"); testF.setDomicilio("Loma Plata"); testF.setCasillaDeCorreo(1158); testF.setIdUser(CurrentUser.getInstance().getUser()); testF.setImporteAporte(15000000); testF.setImporteDonacion(25000000); Utils.getInstance().printFactura(testF); } catch (Exception ex) { App.showException(this.getClass().getName(), ex.getMessage(), ex); } }
From source file:no.ntnu.okse.core.messaging.Message.java
/** * Flags this message as processed. This is a one-time operation and cannot be updated further. * * @return The LocalDateTime object representing the time at which this command was first run. *///from w w w.ja v a 2 s . c o m public LocalDateTime setProcessed() { if (!isProcessed()) this.processed = LocalDateTime.now(); return this.processed; }
From source file:com.ccserver.digital.service.CreditCardApplicationExtractionServiceTest.java
@Test public void extractByteArrayExcelCsv() throws IOException { List<CreditCardApplication> applicationList = new ArrayList<>(); CreditCardApplication creditCardApplication = new CreditCardApplication(); creditCardApplication.setFirstName("First Name"); creditCardApplication.setLastName("Last Name"); creditCardApplication.setPassportNumber("121213"); creditCardApplication.setEmail("Email"); creditCardApplication.setBusinessStartDate(LocalDateTime.now()); creditCardApplication.setDateOfIssue(null); applicationList.add(creditCardApplication); Mockito.when(repository.findAll()).thenReturn(applicationList); byte[] result = ccAppExtractionService.extractCreditCard(0); Assert.assertNotNull(result);//from w w w . jav a 2 s . com }
From source file:nc.noumea.mairie.appock.services.impl.DemandeServiceImpl.java
@Override public void transmetDemande(Demande demande) throws UnsupportedEncodingException, MessagingException { demande.setEtatDemande(EtatDemande.EN_ATTENTE_TRAITEMENT); demande.setDateTransmission(LocalDateTime.now()); AppUser currentUser = authHelper.getCurrentUser(); demande.setTransmetLogin(currentUser.getLogin()); demande.setTransmetUser(currentUser.getNomComplet()); demande = save(demande);/*from www . j a v a 2 s . c o m*/ mailService.sendMailSuiteTransmissionDemande(demande); }
From source file:org.thingsboard.server.dao.audit.sink.ElasticsearchAuditLogSink.java
private String getIndexName(TenantId tenantId) { String indexName = indexPattern; if (indexName.contains(TENANT_PLACEHOLDER) && tenantId != null) { indexName = indexName.replace(TENANT_PLACEHOLDER, tenantId.getId().toString()); }//from w ww . ja v a2 s . co m if (indexName.contains(DATE_PLACEHOLDER)) { LocalDateTime now = LocalDateTime.now(); DateTimeFormatter formatter = DateTimeFormatter.ofPattern(dateFormat); indexName = indexName.replace(DATE_PLACEHOLDER, now.format(formatter)); } return indexName.toLowerCase(); }
From source file:ch.wisv.areafiftylan.integration.TicketRestIntegrationTest.java
@Test public void testEditTicketType() { User admin = createAdmin();/*from w ww . j av a 2 s . co m*/ TicketType type = new TicketType("testEditType", "Type for edit test", 10, 0, LocalDateTime.now(), false); type = ticketService.addTicketType(type); type.setPrice(15F); //@formatter:off given().header(getXAuthTokenHeaderForUser(admin)).when().contentType(ContentType.JSON).body(type) .put(TICKETS_ENDPOINT + "/types/" + type.getId()).then().statusCode(HttpStatus.SC_OK) .body("object.price", is(15F)); //@formatter:on assertThat(ticketService.getAllTicketTypes()).contains(type); }