List of usage examples for java.time LocalTime of
public static LocalTime of(int hour, int minute)
From source file:org.jgrades.lic.app.utils.LicenceBuilderTest.java
private Product getExampleProduct() { Product product = new Product(); product.setName("prodName"); product.setVersion("prodVersion"); product.setValidFrom(LocalDateTime.of(start, LocalTime.of(0, 0))); product.setValidTo(LocalDateTime.of(stop, LocalTime.of(0, 0))); return product; }
From source file:org.kie.workbench.common.forms.integration.tests.valueprocessing.FormValuesProcessorTest.java
@Test public void testLocalDateFieldTaskFormValuesProcessing() { setupFormValuesProcessor(Collections.singletonList(localDateFieldValueProcessor)); final String LOCAL_DATE_BINDING = "_localDate_", LOCAL_DATE_TIME_BINDING = "_localDateTime_", LOCAL_TIME_BINDING = "_localTime_", OFFSET_DATE_TIME_BINDING = "_offsetDateTime_"; final LocalDate localDate1 = LocalDate.of(1989, 6, 6); final LocalDateTime localDateTime1 = LocalDateTime.of(2000, 5, 2, 3, 4); final LocalTime localTime1 = LocalTime.of(23, 15); //form engine does not support setting custom offset final ZoneOffset zoneOffset1 = OffsetDateTime.now().getOffset(); final OffsetDateTime offsetDateTime1 = OffsetDateTime.of(localDate1, localTime1, zoneOffset1); final Map<String, Object> originalRawValues = new HashMap<String, Object>() { {// www . ja va 2 s . c o m put(LOCAL_DATE_BINDING, localDate1); put(LOCAL_DATE_TIME_BINDING, localDateTime1); put(LOCAL_TIME_BINDING, localTime1); put(OFFSET_DATE_TIME_BINDING, offsetDateTime1); } }; localDateFieldValueProcessor.init(); final Map<String, Object> readFlatValues = formValuesProcessor.readFormValues(localDateTaskForm, originalRawValues, context); final Map<String, Object> writtenRawValues = testWritingFormValues(localDateTaskForm, originalRawValues, readFlatValues, originalRawValues); testReadingFormValues(localDateTaskForm, writtenRawValues, readFlatValues); }
From source file:org.optaplanner.examples.conferencescheduling.persistence.ConferenceSchedulingGenerator.java
private void createSpeakerList(ConferenceSolution solution, int speakerListSize) { List<Speaker> speakerList = new ArrayList<>(speakerListSize); speakerNameGenerator.predictMaximumSizeAndReset(speakerListSize); for (int i = 0; i < speakerListSize; i++) { Speaker speaker = new Speaker(); speaker.setId((long) i); speaker.setName(speakerNameGenerator.generateNextValue()); Set<Timeslot> unavailableTimeslotSet; List<Timeslot> timeslotList = solution.getTimeslotList(); if (random.nextDouble() < 0.10) { if (random.nextDouble() < 0.25) { // No mornings unavailableTimeslotSet = timeslotList.stream().filter( timeslot -> timeslot.getStartDateTime().toLocalTime().isBefore(LocalTime.of(12, 0))) .collect(Collectors.toCollection(LinkedHashSet::new)); } else if (random.nextDouble() < 0.25) { // No afternoons unavailableTimeslotSet = timeslotList.stream().filter( timeslot -> !timeslot.getStartDateTime().toLocalTime().isBefore(LocalTime.of(12, 0))) .collect(Collectors.toCollection(LinkedHashSet::new)); } else if (random.nextDouble() < 0.25) { // Only 1 day available LocalDate availableDate = timeslotList.get(random.nextInt(timeslotList.size())).getDate(); unavailableTimeslotSet = timeslotList.stream() .filter(timeslot -> !timeslot.getDate().equals(availableDate)) .collect(Collectors.toCollection(LinkedHashSet::new)); } else { unavailableTimeslotSet = timeslotList.stream().filter(timeslot -> random.nextDouble() < 0.10) .collect(Collectors.toCollection(LinkedHashSet::new)); }/* ww w. j a v a2s . c o m*/ } else { unavailableTimeslotSet = new LinkedHashSet<>(timeslotList.size()); } speaker.setUnavailableTimeslotSet(unavailableTimeslotSet); speaker.setRequiredTimeslotTagSet(new LinkedHashSet<>()); speaker.setPreferredTimeslotTagSet(new LinkedHashSet<>()); speaker.setProhibitedTimeslotTagSet(new LinkedHashSet<>()); speaker.setUndesiredTimeslotTagSet(new LinkedHashSet<>()); Set<String> requiredRoomTagSet = new LinkedHashSet<>(); for (Pair<String, Double> roomTagProbability : roomTagProbabilityList) { if (random.nextDouble() < roomTagProbability.getValue() / 20.0) { requiredRoomTagSet.add(roomTagProbability.getKey()); } } speaker.setRequiredRoomTagSet(requiredRoomTagSet); Set<String> preferredRoomTagSet = new LinkedHashSet<>(); for (Pair<String, Double> roomTagProbability : roomTagProbabilityList) { if (random.nextDouble() < roomTagProbability.getValue() / 10.0) { preferredRoomTagSet.add(roomTagProbability.getKey()); } } speaker.setPreferredRoomTagSet(preferredRoomTagSet); speaker.setProhibitedRoomTagSet(new LinkedHashSet<>()); speaker.setUndesiredRoomTagSet(new LinkedHashSet<>()); logger.trace("Created speaker with name ({}).", speaker.getName()); speakerList.add(speaker); } solution.setSpeakerList(speakerList); }