List of usage examples for java.time LocalDate of
public static LocalDate of(int year, int month, int dayOfMonth)
From source file:cz.muni.fi.pv168.AgentManagerImplTest.java
@Test(expected = IllegalArgumentException.class) public void deleteAgentWithNullId() throws Exception { Agent agent = newAgent("James Bond", LocalDate.of(1950, 1, 1)); agent.setId(null);/*w w w . j a v a 2 s. c o m*/ manager.deleteAgent(agent); }
From source file:org.openmrs.module.operationtheater.OperationTheaterModuleActivator.java
private Patient getEmergencyPatient(PatientIdentifierType patientIdentifierType, LocationService locationService) { Patient patient = new Patient(); patient.setUuid(OTMetadata.PLACEHOLDER_PATIENT_UUID); PersonName pName = new PersonName(); String gender = "M"; boolean male = gender.equals("M"); pName.setGivenName("EMERGENCY"); pName.setFamilyName("PLACEHOLDER PATIENT"); patient.addName(pName);//w ww . j av a 2 s . c om patient.setBirthdate(Date.from(LocalDate.of(1970, 1, 1).atStartOfDay(ZoneId.systemDefault()).toInstant())); patient.setBirthdateEstimated(false); patient.setGender(gender); PatientIdentifier pa1 = new PatientIdentifier(); pa1.setIdentifier(idService.generateIdentifier(patientIdentifierType, "EmergencyData")); pa1.setIdentifierType(patientIdentifierType); pa1.setDateCreated(new Date()); pa1.setLocation(locationService.getLocation(1)); patient.addIdentifier(pa1); return patient; }
From source file:cz.muni.fi.pv168.AgentManagerImplTest.java
@Test(expected = IllegalArgumentException.class) public void deleteAgentWithWrongId() throws Exception { Agent agent = newAgent("James Bond", LocalDate.of(1950, 1, 1)); agent.setId(1L);/*from w w w . j av a 2 s . co m*/ manager.deleteAgent(agent); }
From source file:cz.muni.fi.pv168.project.hotelmanager.TestReservationManagerImpl.java
@Test public void testUpdateReservation() { LocalDate checkin = LocalDate.of(2016, 8, 7); LocalDate checkout = LocalDate.of(2016, 8, 11); LocalDate reservationdate = LocalDate.now(prepareClockMock(now)); Reservation reservation1 = setReservation(1L, 1L, checkin, checkout, reservationdate); Reservation reservation2 = setReservation(2L, 2L, checkin.plusDays(1), checkout, reservationdate.plusDays(2)); reservationManager.createReservation(reservation1); reservationManager.createReservation(reservation2); Long reservationId = reservation1.getReservationId(); reservation1 = reservationManager.findReservation(reservationId); reservation1.setRoomId(3L);/*from w ww. jav a 2s. com*/ reservationManager.updateReservation(reservation1); assertThat("room id was not changed", reservation1.getRoomId(), is(equalTo(3L))); assertThat("guest id was changed", reservation1.getGuestId(), is(equalTo(1L))); assertThat("resrvation date was changed", reservation1.getReservationDate(), is(equalTo(reservationdate))); assertThat("checkin date was changed", reservation1.getCheckinDate(), is(equalTo(checkin))); assertThat("checkout date was changed", reservation1.getCheckoutDate(), is(equalTo(checkout))); reservation1 = reservationManager.findReservation(reservationId); reservation1.setGuestId(3L); reservationManager.updateReservation(reservation1); assertThat("room id was changed", reservation1.getRoomId(), is(equalTo(3L))); assertThat("guest id was not changed", reservation1.getGuestId(), is(equalTo(3L))); assertThat("resrvation date was changed", reservation1.getReservationDate(), is(equalTo(reservationdate))); assertThat("checkin date was changed", reservation1.getCheckinDate(), is(equalTo(checkin))); assertThat("checkout date was changed", reservation1.getCheckoutDate(), is(equalTo(checkout))); reservation1 = reservationManager.findReservation(reservationId); reservation1.setReservationDate(reservationdate.plusDays(1)); reservationManager.updateReservation(reservation1); assertThat("room id was changed", reservation1.getRoomId(), is(equalTo(3L))); assertThat("guest id was changed", reservation1.getGuestId(), is(equalTo(3L))); assertThat("resrvation date was not changed", reservation1.getReservationDate(), is(equalTo(reservationdate.plusDays(1)))); assertThat("checkin date was changed", reservation1.getCheckinDate(), is(equalTo(checkin))); assertThat("checkout date was changed", reservation1.getCheckoutDate(), is(equalTo(checkout))); reservation1 = reservationManager.findReservation(reservationId); reservation1.setCheckinDate(checkin.plusDays(2)); reservationManager.updateReservation(reservation1); assertThat("room id was changed", reservation1.getRoomId(), is(equalTo(3L))); assertThat("guest id was changed", reservation1.getGuestId(), is(equalTo(3L))); assertThat("resrvation date was changed", reservation1.getReservationDate(), is(equalTo(reservationdate.plusDays(1)))); assertThat("checkin date was not changed", reservation1.getCheckinDate(), is(equalTo(checkin.plusDays(2)))); assertThat("checkout date was changed", reservation1.getCheckoutDate(), is(equalTo(checkout))); reservation1 = reservationManager.findReservation(reservationId); reservation1.setCheckoutDate(checkout.plusDays(2)); reservationManager.updateReservation(reservation1); assertThat("room id was changed", reservation1.getRoomId(), is(equalTo(3L))); assertThat("guest id was changed", reservation1.getGuestId(), is(equalTo(3L))); assertThat("resrvation date was changed", reservation1.getReservationDate(), is(equalTo(reservationdate.plusDays(1)))); assertThat("checkin date was changed", reservation1.getCheckinDate(), is(equalTo(checkin.plusDays(2)))); assertThat("checkout date was not changed", reservation1.getCheckoutDate(), is(equalTo(checkout.plusDays(2)))); assertDeepEquals(reservation2, reservationManager.findReservation(reservation2.getReservationId())); }
From source file:example.app.core.mapping.json.jackson.serialization.JsonToObjectMappingIntegrationTests.java
@Test public void convertPieDoeJsonToContactIsSuccessful() throws Exception { ObjectMapper objectMapper = LocalDateDeserializer.register(new ObjectMapper()); Contact contact = objectMapper.readValue(toInputStream("/pieDoeWithBirthDateContact.json"), Contact.class); System.err.printf("Contact is [%s]%n", contact); assertThat(contact).isNotNull();/* ww w. j a va2 s . c o m*/ assertThat(contact.getId()).isEqualTo(3L); assertThat(contact.getEmail()).isEqualTo("pieDoe@springone.com"); Person pieDoe = contact.getPerson(); assertPerson(pieDoe, "Pie Doe", Gender.FEMALE, LocalDate.of(2000, Month.AUGUST, 4)); Address address = contact.getAddress(); assertAddress(address, "3730 S Las Vegas Blvd", "Las Vegas", State.NEVADA, "89158"); PhoneNumber phoneNumber = contact.getPhoneNumber(); assertPhoneNumber(phoneNumber, "702", "590", "7111", null); }
From source file:com.geometrycloud.happydonut.ui.ChartFilterPanel.java
/** * Obtiene una instancia de del timpo local. * * @param panel panel de fecha.//from w ww. j av a2 s. co m * @return instancia del tiempo. */ private LocalDate build(JDatePanel panel) { DateModel<?> model = panel.getModel(); return LocalDate.of(model.getYear(), model.getMonth() + 1, model.getDay()); }
From source file:org.openlmis.fulfillment.web.ProofOfDeliveryControllerIntegrationTest.java
/** * Prepare the test environment./*from w w w .j a v a 2 s .co m*/ */ @Before public void setUp() { this.setUpBootstrapData(); OrderableDto product = new OrderableDto(); product.setId(UUID.randomUUID()); FacilityDto facility = new FacilityDto(); facility.setId(UUID.randomUUID()); facility.setCode("facilityCode"); facility.setName("facilityName"); facility.setDescription("facilityDescription"); facility.setActive(true); facility.setEnabled(true); SupervisoryNodeDto supervisoryNode = new SupervisoryNodeDto(); supervisoryNode.setId(UUID.randomUUID()); supervisoryNode.setCode("NodeCode"); supervisoryNode.setName("NodeName"); supervisoryNode.setFacility(facility); ProgramDto program = new ProgramDto(); program.setId(UUID.randomUUID()); program.setCode("programCode"); ProcessingPeriodDto period = new ProcessingPeriodDto(); period.setId(UUID.randomUUID()); period.setProcessingSchedule(new ProcessingScheduleDto()); period.setName("periodName"); period.setStartDate(LocalDate.of(2015, Month.JANUARY, 1)); period.setEndDate(LocalDate.of(2015, Month.DECEMBER, 31)); Order order = new Order(); order.setId(UUID.randomUUID()); order.setExternalId(UUID.randomUUID()); order.setProgramId(program.getId()); order.setFacilityId(facility.getId()); order.setProcessingPeriodId(period.getId()); order.setEmergency(false); order.setStatus(OrderStatus.SHIPPED); order.setCreatedDate(ZonedDateTime.now()); order.setCreatedById(UUID.randomUUID()); order.setOrderCode("O1"); order.setProgramId(program.getId()); order.setQuotedCost(new BigDecimal(100)); order.setSupplyingFacilityId(facility.getId()); order.setRequestingFacilityId(facility.getId()); order.setReceivingFacilityId(facility.getId()); given(orderRepository.findOne(order.getId())).willReturn(order); given(orderRepository.exists(order.getId())).willReturn(true); OrderLineItem orderLineItem = new OrderLineItem(); orderLineItem.setId(UUID.randomUUID()); orderLineItem.setOrderableId(product.getId()); orderLineItem.setOrderedQuantity(100L); orderLineItem.setFilledQuantity(100L); orderLineItem.setApprovedQuantity(0L); orderLineItem.setPacksToShip(100L); proofOfDeliveryLineItem.setId(UUID.randomUUID()); proofOfDeliveryLineItem.setOrderLineItem(orderLineItem); proofOfDeliveryLineItem.setQuantityShipped(100L); proofOfDeliveryLineItem.setQuantityReturned(100L); proofOfDeliveryLineItem.setQuantityReceived(100L); proofOfDeliveryLineItem.setReplacedProductCode("replaced product code"); proofOfDeliveryLineItem.setNotes("Notes"); proofOfDelivery.setId(UUID.randomUUID()); proofOfDelivery.setOrder(order); proofOfDelivery.setDeliveredBy("delivered by"); proofOfDelivery.setReceivedBy("received by"); proofOfDelivery.setReceivedDate(ZonedDateTime.now()); proofOfDelivery.setProofOfDeliveryLineItems(new ArrayList<>()); proofOfDelivery.getProofOfDeliveryLineItems().add(proofOfDeliveryLineItem); proofOfDeliveryDto = ProofOfDeliveryDto.newInstance(proofOfDelivery, exporter); given(proofOfDeliveryRepository.findOne(proofOfDelivery.getId())).willReturn(proofOfDelivery); given(proofOfDeliveryRepository.findOne(proofOfDeliveryId)).willReturn(null); given(proofOfDeliveryRepository.exists(proofOfDelivery.getId())).willReturn(true); given(proofOfDeliveryRepository.save(any(ProofOfDelivery.class))) .willAnswer(new SaveAnswer<ProofOfDelivery>()); }
From source file:ca.phon.session.io.xml.v12.XMLSessionReader_v12.java
/** * Read session in from given xml {@link SessionType} object. * //w w w. j av a2 s . c o m * @param sessionType * * @return session */ private Session readSessionType(SessionType sessionType) { final SessionFactory factory = SessionFactory.newFactory(); final Session retVal = factory.createSession(); // copy header info retVal.setName(sessionType.getId()); retVal.setCorpus(sessionType.getCorpus()); final HeaderType headerData = sessionType.getHeader(); if (headerData != null) { if (headerData.getMedia() != null && headerData.getMedia().length() > 0) { retVal.setMediaLocation(headerData.getMedia()); } if (headerData.getDate() != null) { final XMLGregorianCalendar xmlDate = headerData.getDate(); final LocalDate dateTime = LocalDate.of(xmlDate.getYear(), xmlDate.getMonth(), xmlDate.getDay()); retVal.setDate(dateTime); } if (headerData.getLanguage().size() > 0) { String langs = ""; for (String lang : headerData.getLanguage()) { langs += (langs.length() > 0 ? " " : "") + lang; } retVal.setLanguage(langs); } } // copy participant information final ParticipantsType participants = sessionType.getParticipants(); if (participants != null) { for (ParticipantType pt : participants.getParticipant()) { final Participant p = copyParticipant(factory, pt, retVal.getDate()); retVal.addParticipant(p); } } // copy transcriber information final TranscribersType transcribers = sessionType.getTranscribers(); if (transcribers != null) { for (TranscriberType tt : transcribers.getTranscriber()) { final Transcriber t = copyTranscriber(factory, tt); retVal.addTranscriber(t); } } // copy tier information final UserTiersType userTiers = sessionType.getUserTiers(); if (userTiers != null) { for (UserTierType utt : userTiers.getUserTier()) { final TierDescription td = copyTierDescription(factory, utt); retVal.addUserTier(td); } } final List<TierViewItem> tierOrder = new ArrayList<TierViewItem>(); for (TvType tot : sessionType.getTierOrder().getTier()) { final TierViewItem toi = copyTierViewItem(factory, tot); tierOrder.add(toi); } retVal.setTierView(tierOrder); // copy transcript data final List<Comment> recordComments = new ArrayList<Comment>(); boolean foundFirstRecord = false; if (sessionType.getTranscript() != null) { for (Object uOrComment : sessionType.getTranscript().getUOrComment()) { if (uOrComment instanceof CommentType) { final CommentType ct = (CommentType) uOrComment; final Comment comment = copyComment(factory, ct); recordComments.add(comment); } else { if (!foundFirstRecord && recordComments.size() > 0) { // add record comments to session metadata for (Comment c : recordComments) { retVal.getMetadata().addComment(c); } recordComments.clear(); } final RecordType rt = (RecordType) uOrComment; Record record = null; try { record = new LazyRecord(factory, retVal, rt); } catch (Exception e) { LOGGER.info(rt.getId()); LOGGER.log(Level.SEVERE, e.getLocalizedMessage(), e); } retVal.addRecord(record); for (Comment comment : recordComments) { record.addComment(comment); } recordComments.clear(); foundFirstRecord = true; } } } return retVal; }
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>() { {/*from w w w . j a v a 2 s.c om*/ 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:io.manasobi.utils.DateUtils.java
/** * ? ? ? ? .//from w w w . j a va 2 s . c om * * @param year ? * @return year? ? true false */ public static boolean isLeapYear(int year) { return LocalDate.of(year, 1, 1).isLeapYear(); }