List of usage examples for java.time ZonedDateTime now
public static ZonedDateTime now()
From source file:org.cgiar.ccafs.marlo.action.center.summaries.ImpactSubmissionSummaryAction.java
/** * Get the main information of the report * //from w w w . j a v a 2s.c o m * @return */ private TypedTableModel getMasterTableModel() { // Initialization of Model TypedTableModel model = new TypedTableModel( new String[] { "title", "current_date", "impact_submission", "imageUrl" }, new Class[] { String.class, String.class, String.class, String.class }); String title = ""; String currentDate = ""; String impactSubmission = ""; // Get title composed by center-area-program if (researchProgram.getResearchArea() != null) { title += researchProgram.getResearchArea().getName() + " - "; if (researchProgram.getComposedName() != null) { title += researchProgram.getName(); } } // Get datetime ZonedDateTime timezone = ZonedDateTime.now(); DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-d 'at' HH:mm "); currentDate = timezone.format(format) + this.getTimeZone(); // Get submission researchCycle = cycleService.getResearchCycleById(ImpactPathwayCyclesEnum.IMPACT_PATHWAY.getId()); // Filling submission List<CenterSubmission> submissions = new ArrayList<>(); for (CenterSubmission submission : researchProgram.getCenterSubmissions().stream() .filter(s -> s.getResearchCycle().getId() == researchCycle.getId() && s.getYear() == this.getActualPhase().getYear()) .collect(Collectors.toList())) { submissions.add(submission); } if (!submissions.isEmpty()) { if (submissions.size() > 1) { LOG.error("More than one submission was found, the report will retrieve the first one"); } CenterSubmission fisrtSubmission = submissions.get(0); String submissionDate = new SimpleDateFormat("yyyy-MM-dd 'at' HH:mm") .format(fisrtSubmission.getDateTime()); impactSubmission = "Submitted on " + submissionDate + " (" + fisrtSubmission.getResearchCycle().getName() + " cycle " + fisrtSubmission.getYear() + ")"; } else { impactSubmission = "Center Submission for " + researchCycle.getName() + " cycle " + this.getActualPhase().getYear() + ": <pending>"; } // Get CIAT imgage URL from repo String imageUrl = this.getBaseUrl() + "/global/images/centers/CIAT.png"; model.addRow(new Object[] { title, currentDate, impactSubmission, imageUrl }); return model; }
From source file:org.cgiar.ccafs.marlo.action.center.summaries.IPOutcomesSummaryAction.java
/** * Get the main information of the report * // w ww. j a va2 s .c o m * @return */ private TypedTableModel getMasterTableModel() { // Initialization of Model TypedTableModel model = new TypedTableModel(new String[] { "currentDate", "center", "researchProgram" }, new Class[] { String.class, String.class, String.class }); String currentDate = ""; // Get datetime ZonedDateTime timezone = ZonedDateTime.now(); DateTimeFormatter format = DateTimeFormatter.ofPattern("yyyy-MM-d 'at' HH:mm "); currentDate = timezone.format(format) + this.getTimeZone(); // Get CIAT imgage URL from repo String center = this.getCenterSession(); model.addRow(new Object[] { currentDate, center, researchProgram.getName() }); return model; }
From source file:org.openlmis.fulfillment.web.OrderControllerIntegrationTest.java
private Order createOrder(UUID processingPeriodId, UUID program, UUID facilityId, UUID supplyingFacilityId, BigDecimal cost, OrderLineItem... lineItems) { Order order = new OrderDataBuilder().withProcessingPeriodId(processingPeriodId).withQuotedCost(cost) .withProgramId(program).withCreatedById(INITIAL_USER_ID).withFacilityId(facilityId) .withRequestingFacilityId(facilityId).withReceivingFacilityId(facilityId) .withSupplyingFacilityId(supplyingFacilityId).withLineItems(lineItems) .withUpdateDetails(new UpdateDetailsDataBuilder().withUpdaterId(UUID.randomUUID()) .withUpdatedDate(ZonedDateTime.now()).build()) .build();/*from w w w .j av a2 s . c om*/ given(orderRepository.findOne(order.getId())).willReturn(order); given(orderRepository.exists(order.getId())).willReturn(true); return order; }
From source file:com.mycompany.projecta.CommonTasks.java
@Override public void LogMessage(String logPath, String logMessage) { try (Writer writer = new BufferedWriter( new OutputStreamWriter(new FileOutputStream(logPath, true), "utf-8"))) { writer.write(logMessage + ZonedDateTime.now() + "\n"); }//from w w w . java2 s .com catch (Exception ex) { ex.printStackTrace(System.out); } }
From source file:org.apache.servicecomb.demo.springmvc.tests.SpringMvcIntegrationTestBase.java
@Test public void ableToPostDate() throws Exception { ZonedDateTime date = ZonedDateTime.now().truncatedTo(SECONDS); MultiValueMap<String, String> body = new LinkedMultiValueMap<>(); body.add("date", RestObjectMapperFactory.getRestObjectMapper().convertToString(Date.from(date.toInstant()))); HttpHeaders headers = new HttpHeaders(); headers.add(CONTENT_TYPE, APPLICATION_FORM_URLENCODED_VALUE); int seconds = 1; Date result = restTemplate.postForObject(codeFirstUrl + "addDate?seconds={seconds}", new HttpEntity<>(body, headers), Date.class, seconds); assertThat(result, is(Date.from(date.plusSeconds(seconds).toInstant()))); ListenableFuture<ResponseEntity<Date>> listenableFuture = asyncRestTemplate.postForEntity( codeFirstUrl + "addDate?seconds={seconds}", new HttpEntity<>(body, headers), Date.class, seconds); ResponseEntity<Date> dateResponseEntity = listenableFuture.get(); assertThat(dateResponseEntity.getBody(), is(Date.from(date.plusSeconds(seconds).toInstant()))); }
From source file:com.mgmtp.perfload.core.console.LtConsole.java
private void runTest() throws InterruptedException, TimeoutException { awaitLatch(readyLatch, "Timeout waiting until test is ready to be started."); startTimestamp = ZonedDateTime.now(); LOG.info("Running test..."); Payload payload = new Payload(PayloadType.START); for (Client client : clients.values()) { LOG.debug("Sending START signal to daemon {}", client.getClientId()); client.sendMessage(payload);// w w w. j a v a2 s . c o m } }
From source file:eu.fthevenet.binjr.sources.jrds.adapters.JrdsDataAdapter.java
private Graphdesc getGraphDescriptorLegacy(String id) throws DataAdapterException { Instant now = ZonedDateTime.now().toInstant(); try (ByteArrayOutputStream out = new ByteArrayOutputStream()) { try (InputStream in = fetchRawData(id, now.minusSeconds(300), now, false)) { List<String> headers = getDecoder().getDataColumnHeaders(in); Graphdesc desc = new Graphdesc(); desc.seriesDescList = new ArrayList<>(); for (String header : headers) { Graphdesc.SeriesDesc d = new Graphdesc.SeriesDesc(); d.name = header;/*from w w w . j av a 2s .c o m*/ desc.seriesDescList.add(d); } return desc; } } catch (IOException e) { throw new FetchingDataFromAdapterException(e); } }
From source file:alfio.manager.WaitingQueueManagerIntegrationTest.java
@Test public void testAssignTicketToWaitingQueueUnboundedCategory() { LocalDateTime start = LocalDateTime.now().minusMinutes(1); LocalDateTime end = LocalDateTime.now().plusMinutes(20); List<TicketCategoryModification> categories = Collections.singletonList(new TicketCategoryModification(null, "default", AVAILABLE_SEATS, new DateTimeModification(start.toLocalDate(), start.toLocalTime()), new DateTimeModification(end.toLocalDate(), end.toLocalTime()), DESCRIPTION, BigDecimal.TEN, false, "", false, null, null, null, null, null)); configurationManager.saveSystemConfiguration(ConfigurationKeys.ENABLE_WAITING_QUEUE, "true"); Event event = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository) .getKey();//from ww w. j a va 2 s . co m TicketCategory unbounded = ticketCategoryRepository.findByEventId(event.getId()).get(0); TicketReservationModification tr = new TicketReservationModification(); tr.setAmount(AVAILABLE_SEATS - 1); tr.setTicketCategoryId(unbounded.getId()); TicketReservationModification tr2 = new TicketReservationModification(); tr2.setAmount(1); tr2.setTicketCategoryId(unbounded.getId()); TicketReservationWithOptionalCodeModification multi = new TicketReservationWithOptionalCodeModification(tr, Optional.empty()); TicketReservationWithOptionalCodeModification single = new TicketReservationWithOptionalCodeModification( tr2, Optional.empty()); String reservationId = ticketReservationManager.createTicketReservation(event, Collections.singletonList(multi), Collections.emptyList(), DateUtils.addDays(new Date(), 1), Optional.empty(), Optional.empty(), Locale.ENGLISH, false); TotalPrice reservationCost = ticketReservationManager.totalReservationCostWithVAT(reservationId); PaymentResult result = ticketReservationManager.confirm("", null, event, reservationId, "test@test.ch", new CustomerName("Full Name", "Full", "Name", event), Locale.ENGLISH, "", reservationCost, Optional.empty(), Optional.of(PaymentProxy.OFFLINE), false, null, null, null); assertTrue(result.isSuccessful()); String reservationIdSingle = ticketReservationManager.createTicketReservation(event, Collections.singletonList(single), Collections.emptyList(), DateUtils.addDays(new Date(), 1), Optional.empty(), Optional.empty(), Locale.ENGLISH, false); TotalPrice reservationCostSingle = ticketReservationManager .totalReservationCostWithVAT(reservationIdSingle); PaymentResult resultSingle = ticketReservationManager.confirm("", null, event, reservationIdSingle, "test@test.ch", new CustomerName("Full Name", "Full", "Name", event), Locale.ENGLISH, "", reservationCostSingle, Optional.empty(), Optional.of(PaymentProxy.OFFLINE), false, null, null, null); assertTrue(resultSingle.isSuccessful()); assertEquals(0, eventRepository.findStatisticsFor(event.getId()).getDynamicAllocation()); assertTrue( waitingQueueManager.subscribe(event, customerJohnDoe(event), "john@doe.com", null, Locale.ENGLISH)); ticketReservationManager.deleteOfflinePayment(event, reservationIdSingle, false); List<Triple<WaitingQueueSubscription, TicketReservationWithOptionalCodeModification, ZonedDateTime>> subscriptions = waitingQueueManager .distributeSeats(event).collect(Collectors.toList()); assertEquals(1, subscriptions.size()); Triple<WaitingQueueSubscription, TicketReservationWithOptionalCodeModification, ZonedDateTime> subscriptionDetail = subscriptions .get(0); assertEquals("john@doe.com", subscriptionDetail.getLeft().getEmailAddress()); TicketReservationWithOptionalCodeModification reservation = subscriptionDetail.getMiddle(); assertEquals(Integer.valueOf(unbounded.getId()), reservation.getTicketCategoryId()); assertEquals(Integer.valueOf(1), reservation.getAmount()); assertTrue(subscriptionDetail.getRight().isAfter(ZonedDateTime.now())); }
From source file:com.mgmtp.perfload.core.console.LtConsole.java
private void disconnectFromDaemons() throws InterruptedException { doneLatch.await();//from w w w . j a v a 2 s . c o m finishTimestamp = ZonedDateTime.now(); LOG.info("Waiting for status polling to complete..."); Thread.sleep(5000L); execService.shutdownNow(); LOG.info("Disconnecting from daemons..."); for (Client client : clients.values()) { LOG.info("Disconnecting from daemon {}", client.getClientId()); client.sendMessage(new Payload(PayloadType.CONSOLE_DISCONNECTING)); if (shutdownDaemons) { LOG.info("Shutting down daemon {}", client.getClientId()); client.sendMessage(new Payload(PayloadType.SHUTDOWN_DAEMON)); } client.disconnect(); } }
From source file:org.eclipse.hawkbit.repository.test.util.AbstractIntegrationTest.java
/** * Gets a valid cron expression describing a schedule with a single * maintenance window, starting specified number of minutes after current * time./*w ww. ja va2s.c o m*/ * * @param minutesToAdd * is the number of minutes after the current time * * @return {@link String} containing a valid cron expression. */ protected static String getTestSchedule(final int minutesToAdd) { ZonedDateTime currentTime = ZonedDateTime.now(); currentTime = currentTime.plusMinutes(minutesToAdd); return String.format("%d %d %d %d %d ? %d", currentTime.getSecond(), currentTime.getMinute(), currentTime.getHour(), currentTime.getDayOfMonth(), currentTime.getMonthValue(), currentTime.getYear()); }