List of usage examples for java.time LocalDateTime toLocalDate
@Override
public LocalDate toLocalDate()
From source file:com.epam.dlab.backendapi.service.impl.SchedulerJobServiceImpl.java
private boolean isFinishDateMatchesCondition(SchedulerJobDTO dto, LocalDateTime currentDateTime) { return dto.getFinishDate() == null || !currentDateTime.toLocalDate().isAfter(dto.getFinishDate()); }
From source file:com.romeikat.datamessie.core.processing.task.documentProcessing.DocumentsProcessingTask.java
private LocalDate getMinDownloadedDate(final StatelessSession statelessSession) { if (StringUtils.isNotBlank(minDownloadedDate)) { Date parseDate;/*from ww w .j a va2s .com*/ try { parseDate = DateUtils.parseDate(minDownloadedDate, "yyyy-MM-dd"); return DateUtil.toLocalDate(parseDate); } catch (final ParseException e) { final String msg = String.format("Cound not parse minDownloadedDate %s", minDownloadedDate); LOG.error(msg, e); return null; } } final LocalDateTime minDownloadedDateTime = documentDao.getMinDownloaded(statelessSession); if (minDownloadedDateTime == null) { return LocalDate.now(); } final LocalDate minDownloadedDate = minDownloadedDateTime.toLocalDate(); return minDownloadedDate; }
From source file:com.bdb.weather.display.summary.HighLowMedianTempPanel.java
@Override public void chartMouseClicked(ChartMouseEventFX event) { ChartEntity entity = event.getEntity(); ///*from ww w . jav a2 s. c o m*/ // Was a point on the plot selected? // if (entity instanceof XYItemEntity) { XYItemEntity itemEntity = (XYItemEntity) entity; XYDataset dataset = itemEntity.getDataset(); Number x = dataset.getXValue(itemEntity.getSeriesIndex(), itemEntity.getItem()); //ZoneId id = ZoneId.of(ZoneId.systemDefault().getId()); //ZoneOffset offset = ZoneOffset.of(ZoneId.systemDefault().getId()); LocalDateTime time = LocalDateTime.ofInstant(Instant.ofEpochSecond(x.longValue() / 1000), ZoneId.systemDefault()); boolean doubleClick = event.getTrigger().getClickCount() == 2; if (doubleClick) supporter.launchView(viewLauncher, time.toLocalDate()); } }
From source file:alfio.manager.WaitingQueueManagerIntegrationTest.java
private List<TicketCategoryModification> getPreSalesTicketCategoryModifications(boolean firstBounded, int firstSeats, boolean lastBounded, int lastSeats) { LocalDateTime start = LocalDateTime.now().plusMinutes(4); return Arrays.asList( new TicketCategoryModification(null, "defaultFirst", firstSeats, new DateTimeModification(start.toLocalDate(), start.toLocalTime()), new DateTimeModification(LocalDate.now().plusDays(1), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", firstBounded, null, null, null, null, null), new TicketCategoryModification(null, "defaultLast", lastSeats, new DateTimeModification(LocalDate.now().plusDays(1), LocalTime.now()), new DateTimeModification(LocalDate.now().plusDays(2), LocalTime.now()), DESCRIPTION, BigDecimal.TEN, false, "", lastBounded, null, null, null, null, null)); }
From source file:com.epam.dlab.backendapi.service.impl.SchedulerJobServiceImpl.java
/** * Checks if scheduler's time data satisfies existing time parameters. * * @param dto scheduler job data. * @param dateTime existing time data. * @param desiredStatus target exploratory status which has influence for time/date checking ('running' status * requires for checking start time, 'stopped' - for end time, 'terminated' - for * 'terminatedDateTime'). * @return true/false./* w w w . j ava 2 s. c om*/ */ private boolean isSchedulerJobDtoSatisfyCondition(SchedulerJobDTO dto, OffsetDateTime dateTime, UserInstanceStatus desiredStatus) { ZoneOffset zOffset = dto.getTimeZoneOffset(); OffsetDateTime roundedDateTime = OffsetDateTime.of(dateTime.toLocalDate(), LocalTime.of(dateTime.toLocalTime().getHour(), dateTime.toLocalTime().getMinute()), dateTime.getOffset()); LocalDateTime convertedDateTime = ZonedDateTime .ofInstant(roundedDateTime.toInstant(), ZoneId.ofOffset(TIMEZONE_PREFIX, zOffset)) .toLocalDateTime(); return desiredStatus == TERMINATED ? Objects.nonNull(dto.getTerminateDateTime()) && convertedDateTime.toLocalDate().equals(dto.getTerminateDateTime().toLocalDate()) && convertedDateTime.toLocalTime().equals(getDesiredTime(dto, desiredStatus)) : !convertedDateTime.toLocalDate().isBefore(dto.getBeginDate()) && isFinishDateMatchesCondition(dto, convertedDateTime) && getDaysRepeat(dto, desiredStatus) .contains(convertedDateTime.toLocalDate().getDayOfWeek()) && convertedDateTime.toLocalTime().equals(getDesiredTime(dto, desiredStatus)); }
From source file:alfio.manager.WaitingQueueManagerIntegrationTest.java
@Test public void testNoPublicCategoryAvailable() { LocalDateTime start = LocalDateTime.now().minusHours(1); LocalDateTime end = LocalDateTime.now().plusHours(1); List<TicketCategoryModification> categories = Arrays.asList( new TicketCategoryModification(null, "default", 2, new DateTimeModification(start.toLocalDate(), start.toLocalTime()), new DateTimeModification(end.toLocalDate(), end.toLocalTime()), DESCRIPTION, BigDecimal.TEN, false, "", true, null, null, null, null, null), new TicketCategoryModification(null, "default2", 10, new DateTimeModification(start.toLocalDate(), start.toLocalTime()), new DateTimeModification(end.toLocalDate(), end.toLocalTime()), DESCRIPTION, BigDecimal.TEN, true, "", true, null, null, null, null, null)); configurationManager.saveSystemConfiguration(ConfigurationKeys.ENABLE_WAITING_QUEUE, "true"); Pair<Event, String> eventAndUsername = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository); Event event = eventAndUsername.getKey(); List<TicketCategory> ticketCategories = ticketCategoryRepository.findByEventId(event.getId()); TicketCategory first = ticketCategories.stream().filter(tc -> !tc.isAccessRestricted()).findFirst() .orElseThrow(IllegalStateException::new); reserveTickets(event, first, 2);/*from w w w .j a va 2 s. c om*/ assertTrue( waitingQueueManager.subscribe(event, customerJohnDoe(event), "john@doe.com", null, Locale.ENGLISH)); assertTrue(waitingQueueManager.subscribe(event, new CustomerName("John Doe 2", "John", "Doe 2", event), "john@doe2.com", null, Locale.ENGLISH)); ZoneId zoneId = event.getZoneId(); Result<TicketCategory> ticketCategoryResult = eventManager.updateCategory(first.getId(), event, new TicketCategoryModification(first.getId(), first.getName(), 3, fromZonedDateTime(first.getInception(zoneId)), fromZonedDateTime(first.getExpiration(zoneId)), Collections.emptyMap(), first.getPrice(), false, "", true, null, null, null, null, null), eventAndUsername.getValue()); assertTrue(ticketCategoryResult.isSuccess()); assertEquals(1, ticketRepository.countReleasedTicketInCategory(event.getId(), first.getId()).intValue()); //now we should have an extra available ticket List<Triple<WaitingQueueSubscription, TicketReservationWithOptionalCodeModification, ZonedDateTime>> subscriptions = waitingQueueManager .distributeSeats(event).collect(Collectors.toList()); assertEquals(1, subscriptions.size()); }
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();//ww w . j a va2 s .c o 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:alfio.manager.WaitingQueueManagerIntegrationTest.java
@Test public void testAssignTicketToWaitingQueueBoundedCategory() { LocalDateTime start = LocalDateTime.now().minusMinutes(2); 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, "", true, null, null, null, null, null)); configurationManager.saveSystemConfiguration(ConfigurationKeys.ENABLE_WAITING_QUEUE, "true"); Event event = initEvent(categories, organizationRepository, userManager, eventManager, eventRepository) .getKey();/*from w w w.j a v a2 s . com*/ TicketCategory bounded = ticketCategoryRepository.findByEventId(event.getId()).get(0); TicketReservationModification tr = new TicketReservationModification(); tr.setAmount(AVAILABLE_SEATS - 1); tr.setTicketCategoryId(bounded.getId()); TicketReservationModification tr2 = new TicketReservationModification(); tr2.setAmount(1); tr2.setTicketCategoryId(bounded.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(bounded.getId()), reservation.getTicketCategoryId()); assertEquals(Integer.valueOf(1), reservation.getAmount()); assertTrue(subscriptionDetail.getRight().isAfter(ZonedDateTime.now())); }
From source file:alfio.manager.WaitingQueueManagerIntegrationTest.java
@Test public void testAssignTicketToWaitingQueueUnboundedCategorySelected() { LocalDateTime start = LocalDateTime.now().minusHours(1); LocalDateTime end = LocalDateTime.now().plusHours(1); List<TicketCategoryModification> categories = Arrays.asList( 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), new TicketCategoryModification(null, "default2", 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();/* ww w .j a va 2s .c o m*/ List<TicketCategory> ticketCategories = ticketCategoryRepository.findByEventId(event.getId()); TicketCategory first = ticketCategories.get(0); TicketCategory second = ticketCategories.get(1); TicketReservationModification tr2 = new TicketReservationModification(); tr2.setAmount(1); tr2.setTicketCategoryId(second.getId()); TicketReservationModification tr3 = new TicketReservationModification(); tr3.setAmount(1); tr3.setTicketCategoryId(first.getId()); reserveTickets(event, first, AVAILABLE_SEATS - 2); String reservationIdSingleFirst = reserveTickets(event, second, 1); String reservationIdSingleSecond = reserveTickets(event, second, 1); assertEquals(0, eventRepository.findStatisticsFor(event.getId()).getDynamicAllocation()); assertTrue(waitingQueueManager.subscribe(event, customerJohnDoe(event), "john@doe.com", first.getId(), Locale.ENGLISH)); assertTrue(waitingQueueManager.subscribe(event, new CustomerName("John Doe 2", "John", "Doe 2", event), "john@doe2.com", second.getId(), Locale.ENGLISH)); ticketReservationManager.deleteOfflinePayment(event, reservationIdSingleFirst, false); ticketReservationManager.deleteOfflinePayment(event, reservationIdSingleSecond, false); List<Triple<WaitingQueueSubscription, TicketReservationWithOptionalCodeModification, ZonedDateTime>> subscriptions = waitingQueueManager .distributeSeats(event).collect(Collectors.toList()); assertEquals(2, subscriptions.size()); Triple<WaitingQueueSubscription, TicketReservationWithOptionalCodeModification, ZonedDateTime> subscriptionDetail = subscriptions .get(0); assertEquals("john@doe.com", subscriptionDetail.getLeft().getEmailAddress()); TicketReservationWithOptionalCodeModification reservation = subscriptionDetail.getMiddle(); assertEquals(Integer.valueOf(first.getId()), reservation.getTicketCategoryId()); assertEquals(Integer.valueOf(1), reservation.getAmount()); assertTrue(subscriptionDetail.getRight().isAfter(ZonedDateTime.now())); subscriptionDetail = subscriptions.get(1); assertEquals("john@doe2.com", subscriptionDetail.getLeft().getEmailAddress()); reservation = subscriptionDetail.getMiddle(); assertEquals(Integer.valueOf(second.getId()), reservation.getTicketCategoryId()); assertEquals(Integer.valueOf(1), reservation.getAmount()); assertTrue(subscriptionDetail.getRight().isAfter(ZonedDateTime.now())); }
From source file:net.resheim.eclipse.timekeeper.ui.Activator.java
private void installTaxameter() { switch (Platform.getOS()) { case Platform.OS_MACOSX: detector = new MacIdleTimeDetector(); break;/*from w w w . j a v a 2 s. c o m*/ case Platform.OS_LINUX: detector = new X11IdleTimeDetector(); break; case Platform.OS_WIN32: detector = new WindowsIdleTimeDetector(); break; default: detector = new GenericIdleTimeDetector(); break; } Timer timer = new Timer("Timekeeper", true); timer.scheduleAtFixedRate(new TimerTask() { @Override public void run() { if (!PlatformUI.getWorkbench().isClosing()) { long idleTimeMillis = detector.getIdleTimeMillis(); ITask task = TasksUi.getTaskActivityManager().getActiveTask(); if (null != task) { if (idleTimeMillis < lastIdleTime && lastIdleTime > IDLE_INTERVAL) { // Was idle on last check, reactivate Display.getDefault().syncExec(() -> handleReactivation(idleTimeMillis)); } else if (lastIdleTime < IDLE_INTERVAL) { String tickString = Activator.getValue(task, Activator.TICK); LocalDateTime now = LocalDateTime.now(); LocalDateTime ticked = LocalDateTime.parse(tickString); // Currently not idle so accumulate spent time accumulateTime(task, now.toLocalDate().toString(), ticked.until(now, ChronoUnit.MILLIS)); Activator.setValue(task, Activator.TICK, now.toString()); } } lastIdleTime = idleTimeMillis; } } }, SHORT_INTERVAL, SHORT_INTERVAL); // Immediately run the idle handler if the system has been idle and // the user has pressed a key or mouse button _inside_ the running // application. reactivationListener = new Listener() { public void handleEvent(Event event) { long idleTimeMillis = detector.getIdleTimeMillis(); if (idleTimeMillis < lastIdleTime && lastIdleTime > IDLE_INTERVAL) { handleReactivation(idleTimeMillis); } lastIdleTime = idleTimeMillis; } }; final Display display = PlatformUI.getWorkbench().getDisplay(); display.addFilter(SWT.KeyUp, reactivationListener); display.addFilter(SWT.MouseUp, reactivationListener); }