Example usage for java.time LocalDate of

List of usage examples for java.time LocalDate of

Introduction

In this page you can find the example usage for java.time LocalDate of.

Prototype

public static LocalDate of(int year, int month, int dayOfMonth) 

Source Link

Document

Obtains an instance of LocalDate from a year, month and day.

Usage

From source file:com.hengyi.japp.tools.DateTimeUtil.java

public static Date toDate(LocalTime localTime) {
    return localTime == null ? null : toDate(localTime.atDate(LocalDate.of(1977, Month.JANUARY, 1)));
}

From source file:org.lambdamatic.internal.elasticsearch.codec.DocumentSearchCodecTest.java

@Test
public void shouldSerializeDocumentSearch() throws IOException, JSONException {
    // given//from  w w  w .  j  a va  2  s  .c  o m
    final QueryExpression<QBlogpost> mustMatchExpression = b -> b.title.matches("Search")
            && b.content.matches("Elasticsearch");
    final QueryExpression<QBlogpost> filterExpression = b -> b.status.hasExactTerm(BlogpostStatus.PUBLISHED)
            && b.publishDate.isGreaterOrEqualTo(LocalDate.of(2015, 1, 1));
    final DocumentSearch query = DocumentSearchBuilder.mustMatch(mustMatchExpression)
            .andFilter(filterExpression).build();
    // when
    final String jsonSearchRequest = new DocumentSearchCodec().encode(query);
    // then
    final String expectation = loadExpectedContentFromFile("query-filter-context.json");
    LOGGER.debug("Comparing {} \nvs\n {}", expectation, jsonSearchRequest);
    JSONAssert.assertEquals(expectation, jsonSearchRequest, JSONCompareMode.LENIENT);
}

From source file:cz.muni.fi.pv168.AgentManagerImplTest.java

@Test
public void createAgent() {
    Agent agent = newAgent("James Bond", LocalDate.of(1950, 1, 1));
    manager.createAgent(agent);//ww w  . j  a v a  2  s  .  c om

    Long agentId = agent.getId();
    assertThat("saved agent has null id", agent.getId(), is(not(equalTo(null))));

    Agent result = manager.getAgent(agentId);
    assertThat("retrieved agent differs from the saved one", result, is(equalTo(agent)));
    assertThat("retrieved agent is the same instance", result, is(not(sameInstance(agent))));
    assertDeepEquals(agent, result);
}

From source file:com.chadekin.jadys.syntax.SqlNativeQuerySectionDetailedITest.java

@Test
public void shouldBuildAllSqlQuerySection() {
    // Arrange//from  w w  w.j a  v a 2 s  .c  o  m
    Calendar calendar = Calendar.getInstance();
    LocalDate localDate = LocalDate.of(2016, Month.DECEMBER, 14);
    Date date = Date.from(localDate.atStartOfDay(ZoneId.systemDefault()).toInstant());
    String internalSql = DynamicSqlFactory.newQuery().select("cus.Id_").count("*", "cus.numberOfLocation")
            .from("dct_customer").as("cus").join("dct_location", "loc").on("loc.customerId").equal("cus.id_")
            .where("cus.companyId").equal(142576).and("cus.customerId").equal(1258).and("cus.customerName")
            .like("BSD GmbH").and("zipCode").like(StringUtils.EMPTY).and("cus.city").like("Paris")
            .and("country").like(null).and("cus.externalId").like("456753").and("cus.customerType")
            .like(CustomerType.KEY_ACCOUNT).and("cus.modifiedDate").greaterThanOrEqual("2016-10-14")
            .and("cus.modifiedDate").lessThanOrEqual(date).and("cus.modifiedByUserId")
            .in(Lists.newArrayList(125, 36, 587)).groupBy("loc.customerId").having("COUNT(loc.customerId)")
            .equal(2).orderBy("cus.externalId").asc().build();

    // Act
    String sql = DynamicSqlFactory.newQuery().select().count().from(internalSql).as("subQuery").build();

    // Assert
    assertThatSelect(sql);
    assertThatFrom(sql);
    assertThatJoin(sql);
    assertThatWhere(sql);
    assertThatAnd(sql);
    assertThatGroupBy(sql);
    assertThatHaving(sql);
    assertThatOrderBy(sql);
    assertThatAll(sql);
}

From source file:me.yanaga.querydsl.args.core.single.SingleLocalDateArgumentTest.java

@Test
public void testAppendDefaultOneArgument() {
    SingleLocalDateArgument argument = SingleLocalDateArgument.of(LocalDate.of(2015, 2, 25));
    BooleanBuilder builder = new BooleanBuilder();
    argument.append(builder, QPerson.person.oneLocalDate);
    Person result = new JPAQuery(entityManager).from(QPerson.person).where(builder)
            .uniqueResult(QPerson.person);
    assertThat(result).isNotNull();//from w  ww . ja  va 2  s. co m
    assertThat(result.getOneLocalDate()).isEqualTo(LocalDate.of(2015, 2, 25));
}

From source file:com.firevo.product.ProductController.java

@InitBinder
public void initBinder(WebDataBinder binder) {
    binder.registerCustomEditor(ProductColorType.class, new PropertyEditorSupport() {
        @Override/* w  ww  .  j  a  v a 2 s . co  m*/
        public void setAsText(String text) throws IllegalArgumentException {
            setValue(ProductColorType.find(Integer.valueOf(text)));
        }
    });

    binder.registerCustomEditor(ProductShopType.class, new PropertyEditorSupport() {
        @Override
        public void setAsText(String text) throws IllegalArgumentException {
            setValue(ProductShopType.find(Integer.valueOf(text)));
        }
    });

    binder.registerCustomEditor(LocalDate.class, new PropertyEditorSupport() {
        @Override
        public void setAsText(String text) throws IllegalArgumentException {
            try {
                String[] split = text.split(",");
                setValue(LocalDate.of(Integer.valueOf(split[0]), Integer.valueOf(split[1]),
                        Integer.valueOf(split[2])));
            } catch (Exception ex) {
                setValue(null);
            }
        }
    });
}

From source file:fi.helsinki.opintoni.web.rest.privateapi.portfolio.PrivateDegreeResourceTest.java

@Test
public void thatDegreesAreUpdated() throws Exception {
    UpdateDegree updateDegree = new UpdateDegree();
    updateDegree.title = "Degree Title";
    updateDegree.description = "Degree description";
    updateDegree.dateOfDegree = LocalDate.of(2016, 6, 6);

    mockMvc.perform(post("/api/private/v1/portfolio/2/degree").with(securityContext(studentSecurityContext()))
            .content(WebTestUtils.toJsonBytes(newArrayList(updateDegree)))
            .contentType(MediaType.APPLICATION_JSON)).andExpect(status().isOk())
            .andExpect(jsonPath("$").isArray()).andExpect(jsonPath("$", hasSize(1)))
            .andExpect(jsonPath("$[0].title").value("Degree Title"))
            .andExpect(jsonPath("$[0].description").value("Degree description"))
            .andExpect(jsonPath("$[0].dateOfDegree[0]").value(2016))
            .andExpect(jsonPath("$[0].dateOfDegree[1]").value(6))
            .andExpect(jsonPath("$[0].dateOfDegree[2]").value(6));
}

From source file:me.yanaga.querydsl.args.core.single.SingleComparableArgumentTest.java

@Test
public void testAppendDefaultWithOneArgument() {
    CustomComparableType value = CustomComparableType.of(LocalDate.of(2015, 2, 26));
    SingleComparableArgument<CustomComparableType> argument = SingleComparableArgument.of(value);
    BooleanBuilder builder = new BooleanBuilder();
    argument.append(builder, QPerson.person.oneCustomComparableType);
    SingleArgument.of(value).append(builder, QPerson.person.oneCustomComparableType);
    Person result = new JPAQuery(entityManager).from(QPerson.person).where(builder)
            .uniqueResult(QPerson.person);
    assertThat(result.getOneCustomComparableType()).isEqualTo(value);
}

From source file:defaultmethods.SimpleTimeClient.java

public void setDate(int day, int month, int year) {
    LocalDate dateToSet = LocalDate.of(day, month, year);
    LocalTime currentTime = LocalTime.from(dateAndTime);
    dateAndTime = LocalDateTime.of(dateToSet, currentTime);
}

From source file:cz.muni.fi.javaseminar.kafa.bookregister.AuthorManagerImplTest.java

@Before
public void setUp() throws SQLException, FileNotFoundException {
    manager = (AuthorManagerImpl) CTX.getBean("authorManager");
    dataSource = manager.getDataSource();
    DBUtils.executeSqlScript(dataSource, BookManager.class.getResource(SQL_SCRIPT_NAME));

    authorOlda = Author.builder().firstname("Oldrich").surname("Faldik").nationality("Czech")
            .description("Novodoby autor").dateOfBirth(LocalDate.of(1990, Month.JANUARY, 20));

    authorKarel = Author.builder().firstname("Karel").surname("Soukup").nationality("Czech")
            .description("Stredovek").dateOfBirth(LocalDate.of(1450, Month.AUGUST, 12));
}