List of usage examples for java.time LocalDateTime now
public static LocalDateTime now()
From source file:fi.vrk.xroad.catalog.persistence.CatalogServiceImpl.java
@Override public void saveAllMembersAndSubsystems(Collection<Member> members) { LocalDateTime now = LocalDateTime.now(); // process members Map<MemberId, Member> unprocessedOldMembers = new HashMap<>(); StreamSupport.stream(memberRepository.findAll().spliterator(), false) .forEach(member -> unprocessedOldMembers.put(member.createKey(), member)); for (Member member : members) { Member oldMember = unprocessedOldMembers.get(member.createKey()); if (oldMember == null) { // brand new item member.getStatusInfo().setTimestampsForNew(now); for (Subsystem subsystem : member.getAllSubsystems()) { subsystem.getStatusInfo().setTimestampsForNew(now); subsystem.setMember(member); }// w ww.j a va 2 s . co m member = memberRepository.save(member); } else { handleOldMember(now, member, oldMember); member = memberRepository.save(oldMember); } unprocessedOldMembers.remove(member.createKey()); } // now unprocessedOldMembers should all be removed (either already removed, or will be now) removeUnprocessedOldMembers(now, unprocessedOldMembers); }
From source file:com.romeikat.datamessie.core.base.util.FileUtil.java
public synchronized String createTargetDir() { try {//w ww. j a v a 2s. c o m final String dirName = LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd_HH-mm-ss")); Path dir = Paths.get(exportDir, dirName); dir = getNonExisting(dir); Files.createDirectories(dir); return dir.toString(); } catch (final Exception e) { LOG.error("Could not create target directory", e); return null; } }
From source file:br.ufac.sion.service.retorno.ArquivoRetornoBradescoService.java
private void carregarTitulos(ArquivoRetornoBradesco arquivoRetorno) { Map<Integer, Collection<TransacaoTitulo>> titulosPorOcorrencia = arquivoRetorno .getTransacoesPorCodigoDeOcorrencia(); int totalTitulosPagos = 0; for (TransacaoTitulo t : titulosPorOcorrencia.get(TransacaoTitulo.LIQUIDACAO)) { br.ufac.sion.model.Boleto cobranca = this.boletoFacade.findByNossoNumero(t.getNossoNumeroComDigito()); if (cobranca != null) { if (t.getValorPago().compareTo(cobranca.getValor()) >= 0) { cobranca.getSacado().setStatus(SituacaoInscricao.CONFIRMADA); cobranca.getSacado()/* ww w .j a v a2s . c o m*/ .setJustificativaStatus("Confirmao automtica (via arquivo de retorno)"); cobranca.getSacado().setDataJustificativaStatus(LocalDateTime.now()); cobranca.setSituacao(SituacaoBoleto.PAGO); cobranca.setDataPagamento(DateConversor.convertDateToLocalDate(t.getDataDoCredito())); cobranca.setValorPago(t.getValorPago()); cobranca.setArquivo(ar); this.ard.getIncricoesConfirmadas().add(cobranca.getSacado()); totalTitulosPagos++; } } } this.ard.setTotalTitulosPagos(totalTitulosPagos); }
From source file:com.swcguild.capstoneproject.dao.BlogDaoInMemImplTest.java
/** * Test of updatePost method, of class BlogDaoInMemImpl. *///w ww. j a v a 2 s. c o m @Test public void testUpdatePost() { System.out.println("updatePost"); Post post1 = new Post("SuperMAN", "Clark Kent", "hot new cousin saves city", "super, girl", LocalDateTime.now().toString(), "12-30-2015"); BlogDaoInMemImpl instance = new BlogDaoInMemImpl(); instance.updatePost(post1); assertEquals("SuperMAN", post1.getTitle()); }
From source file:org.ow2.proactive.workflow_catalog.rest.service.BucketServiceTest.java
@Test public void testGetBucketMetadataValidBucket() throws Exception { Bucket mockedBucket = newMockedBucket(1L, "BUCKET-NAME-TEST", LocalDateTime.now()); when(bucketRepository.findOne(anyLong())).thenReturn(mockedBucket); BucketMetadata bucketMetadata = bucketService.getBucketMetadata(1L); verify(bucketRepository, times(1)).findOne(anyLong()); assertEquals(mockedBucket.getName(), bucketMetadata.name); assertEquals(mockedBucket.getCreatedAt(), bucketMetadata.createdAt); assertEquals(mockedBucket.getId(), bucketMetadata.id); }
From source file:org.wallride.service.CommentService.java
public Comment updateComment(CommentUpdateRequest request, AuthorizedUser updatedBy) { Comment comment = commentRepository.findOneForUpdateById(request.getId()); if (comment == null) { throw new ServiceException(); }//from ww w . ja v a2 s . com if (!updatedBy.getRoles().contains(User.Role.ADMIN) || !ObjectUtils.nullSafeEquals(comment.getAuthor(), updatedBy)) { throw new ServiceException(); } LocalDateTime now = LocalDateTime.now(); comment.setContent(request.getContent()); comment.setUpdatedAt(now); comment.setUpdatedBy(updatedBy.toString()); return commentRepository.saveAndFlush(comment); }
From source file:com.qq.tars.service.config.ConfigService.java
@Transactional(rollbackFor = Exception.class) public ConfigFile addConfigFile(AddConfigFile params) { int level = params.getLevel(); Preconditions.checkState(level >= 1 && level <= 5); ConfigFile configFile = new ConfigFile(); configFile.setLevel(level == 5 ? 2 : 1); String server;/*from w ww . j a va 2 s . com*/ if (configFile.getLevel() == 1) { Preconditions.checkState(StringUtils.isNoneBlank(params.getApplication())); server = params.getApplication(); } else { Preconditions.checkState(StringUtils.isNoneBlank(params.getApplication(), params.getServerName())); server = String.format("%s.%s", params.getApplication(), params.getServerName()); } configFile.setServerName(server); if (StringUtils.isNotBlank(params.getSetName())) { configFile.setSetName(params.getSetName()); } if (StringUtils.isNotBlank(params.getSetArea())) { configFile.setSetArea(params.getSetArea()); } if (StringUtils.isNotBlank(params.getSetGroup())) { configFile.setSetGroup(params.getSetGroup()); } Preconditions.checkState(StringUtils.isNotBlank(params.getFilename())); configFile.setFilename(params.getFilename()); configFile.setConfig(StringUtils.trimToEmpty(params.getConfig())); configFile.setPosttime(LocalDateTime.now().format(DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"))); configMapper.insertConfigFile(configFile); ConfigFileHistory history = new ConfigFileHistory(); history.setConfigId(configFile.getId()); history.setReason("?"); history.setContent(configFile.getConfig()); history.setPosttime(configFile.getPosttime()); configMapper.insertConfigFileHistory(history); // ?? if (configFile.getLevel() == 2) { boolean enableSet = StringUtils.isNoneBlank(params.getSetName(), params.getSetArea(), params.getSetGroup()); addDefaultNodeConfigFile(params.getApplication(), params.getServerName(), enableSet, params.getSetName(), params.getSetArea(), params.getSetGroup(), params.getFilename()); } return configFile; }
From source file:com.fns.grivet.service.NamedQueryServiceSelectTest.java
@Test public void testGetQueryNotFound() throws IOException { Assertions.assertThrows(IllegalArgumentException.class, () -> { MultiValueMap<String, String> params = new LinkedMultiValueMap<>(); params.add("createdTime", LocalDateTime.now().plusDays(1).toString()); namedQueryService.get("getAttributesCreatedBefore", params); });/*from w w w. j ava 2s . co m*/ }
From source file:nc.noumea.mairie.appock.services.impl.ConfigServiceImpl.java
private boolean isCacheARecharger() { return cacheCleValeur == null || dateCache == null || LocalDateTime.now().isAfter(dateCache.plusMinutes(5)); }
From source file:com.nirmata.workflow.details.TestJsonSerializer.java
@Test public void testRunnableTask() { Map<TaskId, ExecutableTask> tasks = Stream.generate(() -> "").limit(random.nextInt(3) + 1) .collect(Collectors.toMap(s -> new TaskId(), s -> new ExecutableTask(new RunId(), new TaskId(), randomTaskType(), randomMap(), random.nextBoolean()))); List<RunnableTaskDag> taskDags = Stream.generate(() -> new RunnableTaskDag(new TaskId(), randomTasks())) .limit(random.nextInt(3) + 1).collect(Collectors.toList()); LocalDateTime completionTime = random.nextBoolean() ? LocalDateTime.now() : null; RunId parentRunId = random.nextBoolean() ? new RunId() : null; RunnableTask runnableTask = new RunnableTask(tasks, taskDags, LocalDateTime.now(), completionTime, parentRunId);// ww w .ja v a 2s .c o m JsonNode node = newRunnableTask(runnableTask); String str = nodeToString(node); System.out.println(str); RunnableTask unRunnableTask = getRunnableTask(fromString(str)); Assert.assertEquals(runnableTask, unRunnableTask); }