List of usage examples for java.time LocalDateTime toLocalTime
@Override
public LocalTime toLocalTime()
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 va2s .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: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();/*w w w . j a va 2 s . c om*/ 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: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.// ww w. jav a 2 s . co m */ 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 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();//from w w w . j a v a 2 s . c om 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:org.darkware.wpman.util.TimeWindow.java
/** * Calculates the next time when a given hour and minute occur, based from the given start time. * * @param after The time to start searching from. * @param hour The hour to search for./* www . j a v a2 s. c o m*/ * @param minute The minute to search for. * @return A {@code DateTime} corresponding to the hour and minute declared which is explicitly after * the start time. */ public static LocalDateTime nextTime(final LocalDateTime after, final int hour, final int minute) { LocalTime time = LocalTime.of(hour, minute); LocalDate afterDate = after.toLocalDate(); if (!time.isAfter(after.toLocalTime())) afterDate = afterDate.plus(1, ChronoUnit.DAYS); return time.atDate(afterDate); }
From source file:org.ojbc.adapters.analyticsstaging.custody.processor.AbstractReportRepositoryProcessor.java
protected CustodyRelease processCustodyReleaseInfo(Node parentNode, Integer bookingId, String bookingNumber) throws Exception { String supervisionReleaseDateTimeString = XmlUtils.xPathStringSearch(parentNode, "jxdm51:Detention/jxdm51:SupervisionAugmentation/jxdm51:SupervisionReleaseDate/nc30:DateTime"); LocalDateTime supervisionReleaseDateTime = parseLocalDateTime(supervisionReleaseDateTimeString); CustodyRelease custodyRelease = new CustodyRelease(); if (supervisionReleaseDateTime != null) { custodyRelease.setReleaseDate(supervisionReleaseDateTime.toLocalDate()); custodyRelease.setReleaseTime(supervisionReleaseDateTime.toLocalTime()); } else {//from www . ja va 2 s. c o m String releaseDateString = XmlUtils.xPathStringSearch(parentNode, "jxdm51:Detention/jxdm51:SupervisionAugmentation/jxdm51:SupervisionReleaseDate/nc30:Date"); custodyRelease.setReleaseDate(parseLocalDate(releaseDateString)); } if (custodyRelease.getReleaseDate() != null) { custodyRelease.setBookingId(bookingId); custodyRelease.setBookingNumber(bookingNumber); analyticalDatastoreDAO.saveCustodyRelease(custodyRelease); } return custodyRelease; }
From source file:org.ojbc.adapters.analyticsstaging.custody.processor.BookingReportProcessor.java
@Transactional private Booking processBookingReport(Document report) throws Exception { Node bookingReportNode = XmlUtils.xPathNodeSearch(report, "/br-doc:BookingReport"); String bookingNumber = XmlUtils.xPathStringSearch(bookingReportNode, "jxdm51:Booking/jxdm51:BookingAgencyRecordIdentification/nc30:IdentificationID"); checkBookingNumber(bookingNumber);/* www . java 2 s .c o m*/ Booking booking = new Booking(); booking.setBookingNumber(bookingNumber); Integer personId = processPersonAndBehavioralHealthInfo(report); booking.setPersonId(personId); String bookingDateTimeString = XmlUtils.xPathStringSearch(bookingReportNode, "jxdm51:Booking/nc30:ActivityDate/nc30:DateTime"); LocalDateTime bookingDateTime = parseLocalDateTime(bookingDateTimeString); if (bookingDateTime != null) { booking.setBookingDate(bookingDateTime.toLocalDate()); booking.setBookingTime(bookingDateTime.toLocalTime()); } else { String bookingDateString = XmlUtils.xPathStringSearch(bookingReportNode, "jxdm51:Booking/nc30:ActivityDate/nc30:Date"); booking.setBookingDate(parseLocalDate(bookingDateString)); } String facility = XmlUtils.xPathStringSearch(bookingReportNode, "jxdm51:Booking/jxdm51:BookingDetentionFacility/nc30:FacilityIdentification/nc30:IdentificationID"); Integer facilityId = descriptionCodeLookupService.retrieveCode(CodeTable.Facility, facility); booking.setFacilityId(facilityId); String supervisionUnitType = XmlUtils.xPathStringSearch(bookingReportNode, "jxdm51:Detention/jxdm51:SupervisionAugmentation/jxdm51:SupervisionAreaIdentification/nc30:IdentificationID"); Integer supervisionUnitTypeId = descriptionCodeLookupService.retrieveCode(CodeTable.SupervisionUnitType, supervisionUnitType); booking.setSupervisionUnitTypeId(supervisionUnitTypeId); String supervisionReleaseEligibilityDate = XmlUtils.xPathStringSearch(bookingReportNode, "jxdm51:Detention/jxdm51:SupervisionAugmentation/jxdm51:SupervisionReleaseEligibilityDate/nc30:Date"); booking.setScheduledReleaseDate(parseLocalDate(supervisionReleaseEligibilityDate)); String inmateJailResidentIndicator = XmlUtils.xPathStringSearch(bookingReportNode, "jxdm51:Detention/br-ext:InmateJailResidentIndicator"); booking.setInmateJailResidentIndicator(BooleanUtils.toBooleanObject(inmateJailResidentIndicator)); Integer bookingId = analyticalDatastoreDAO.saveBooking(booking); booking.setBookingId(bookingId); processCustodyReleaseInfo(bookingReportNode, bookingId, bookingNumber); return booking; }
From source file:org.ojbc.adapters.analyticsstaging.custody.processor.CustodyReleaseReportProcessor.java
@Transactional(rollbackFor = Exception.class) public void processReport(Document report) throws Exception { log.info("Processing Custody Release report."); CustodyRelease custodyRelease = new CustodyRelease(); Node bookingNode = XmlUtils.xPathNodeSearch(report, "/crr-exc:CustodyReleaseReport/crr-ext:Custody/jxdm51:Booking"); String bookingNumber = XmlUtils.xPathStringSearch(bookingNode, "jxdm51:BookingAgencyRecordIdentification/nc30:IdentificationID"); Integer bookingId = getBookingIdByBookingNumber(bookingNumber); custodyRelease.setBookingId(bookingId); String releaseCondition = XmlUtils.xPathStringSearch(bookingNode, "following-sibling::nc30:Release/crr-ext:ReleaseCondition/nc30:ActivityDescriptionText"); custodyRelease.setReleaseCondition(releaseCondition); String releaseDateTimeString = XmlUtils.xPathStringSearch(bookingNode, "following-sibling::nc30:Release/nc30:ActivityDate/nc30:DateTime"); LocalDateTime releaseDateTime = parseLocalDateTime(releaseDateTimeString); if (releaseDateTime != null) { custodyRelease.setReleaseDate(releaseDateTime.toLocalDate()); custodyRelease.setReleaseTime(releaseDateTime.toLocalTime()); } else {/*from w w w . j ava2 s . co m*/ String releaseDateString = XmlUtils.xPathStringSearch(bookingNode, "following-sibling::nc30:Release/nc30:ActivityDate/nc30:Date"); custodyRelease.setReleaseDate(parseLocalDate(releaseDateString)); } custodyRelease.setBookingNumber(bookingNumber); analyticalDatastoreDAO.saveCustodyRelease(custodyRelease); processBehavioralHealthInfo(report); log.info("Processed Custody Release report successfully."); }
From source file:org.ojbc.adapters.analyticsstaging.custody.processor.CustodyStatusChangeReportProcessor.java
@Transactional private Integer processCustodyStatusChangeReport(Document report) throws Exception { CustodyStatusChange custodyStatusChange = new CustodyStatusChange(); Node personNode = XmlUtils.xPathNodeSearch(report, "/cscr-doc:CustodyStatusChangeReport/cscr-ext:Custody/nc30:Person"); Node custodyNode = XmlUtils.xPathNodeSearch(report, "/cscr-doc:CustodyStatusChangeReport/cscr-ext:Custody"); String bookingNumber = XmlUtils.xPathStringSearch(custodyNode, "jxdm51:Booking/jxdm51:BookingAgencyRecordIdentification/nc30:IdentificationID"); custodyStatusChange.setBookingNumber(bookingNumber); Integer bookingId = getBookingIdByBookingNumber(bookingNumber); custodyStatusChange.setBookingId(bookingId); Integer personId = processPersonAndBehavioralHealthInfo(personNode, bookingNumber); custodyStatusChange.setPersonId(personId); String bookingDateTimeString = XmlUtils.xPathStringSearch(custodyNode, "jxdm51:Booking/nc30:ActivityDate/nc30:DateTime"); LocalDateTime bookingDateTime = parseLocalDateTime(bookingDateTimeString); if (bookingDateTime != null) { custodyStatusChange.setBookingDate(bookingDateTime.toLocalDate()); custodyStatusChange.setBookingTime(bookingDateTime.toLocalTime()); } else {/*from w ww. j a va2 s. c o m*/ String bookingDateString = XmlUtils.xPathStringSearch(custodyNode, "jxdm51:Booking/nc30:ActivityDate/nc30:Date"); custodyStatusChange.setBookingDate(parseLocalDate(bookingDateString)); } String facility = XmlUtils.xPathStringSearch(custodyNode, "jxdm51:Booking/jxdm51:BookingDetentionFacility/nc30:FacilityIdentification/nc30:IdentificationID"); Integer facilityId = descriptionCodeLookupService.retrieveCode(CodeTable.Facility, facility); custodyStatusChange.setFacilityId(facilityId); String supervisionUnitType = XmlUtils.xPathStringSearch(custodyNode, "jxdm51:Detention/jxdm51:SupervisionAugmentation/jxdm51:SupervisionAreaIdentification/nc30:IdentificationID"); Integer supervisionUnitTypeId = descriptionCodeLookupService.retrieveCode(CodeTable.SupervisionUnitType, supervisionUnitType); custodyStatusChange.setSupervisionUnitTypeId(supervisionUnitTypeId); String supervisionReleaseEligibilityDate = XmlUtils.xPathStringSearch(custodyNode, "jxdm51:Detention/jxdm51:SupervisionAugmentation/jxdm51:SupervisionReleaseEligibilityDate/nc30:Date"); custodyStatusChange.setScheduledReleaseDate(parseLocalDate(supervisionReleaseEligibilityDate)); String inmateJailResidentIndicator = XmlUtils.xPathStringSearch(custodyNode, "jxdm51:Detention/cscr-ext:InmateJailResidentIndicator"); custodyStatusChange .setInmateJailResidentIndicator(BooleanUtils.toBooleanObject(inmateJailResidentIndicator)); processCustodyReleaseInfo(custodyNode, bookingId, bookingNumber); Integer custodyStatusChangeId = analyticalDatastoreDAO.saveCustodyStatusChange(custodyStatusChange); return custodyStatusChangeId; }
From source file:rjc.jplanner.model.DateTime.java
/***************************************** constructor *****************************************/ public DateTime(LocalDateTime dt) { // constructor Date date = new Date(dt.toLocalDate()); Time time = new Time(dt.toLocalTime()); m_milliseconds = date.epochday() * MILLISECONDS_IN_DAY + time.milliseconds(); }