Example usage for java.time LocalDate now

List of usage examples for java.time LocalDate now

Introduction

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

Prototype

public static LocalDate now() 

Source Link

Document

Obtains the current date from the system clock in the default time-zone.

Usage

From source file:dijalmasilva.testes.UsuarioServiceTeste.java

@Test
public void testSalvarUsuario() {
    Usuario u = new Usuario();
    u.setConta("ATIVADA");
    u.setEmail("teste@gmail.com");
    u.setUsername("teste");
    u.setFoto(null);//from  w w  w . j  av a2s  .c o m
    u.setDataDeNascimento(LocalDate.now());
    u.setNome("Teste");
    u.setSenha("teste");
    u.setSobrenome("Salvar");
    Usuario expResult = u;
    Usuario result = service.salvarUsuario(u);
    assertEquals(expResult.getEmail(), result.getEmail());
}

From source file:fi.helsinki.opintoni.integration.oodi.OodiRestClientCacheTest.java

@Test
public void thatTeacherCoursesAreCached() {
    teacherRequestChain("123").courses();

    String sinceDateString = DateTimeUtil.getSemesterStartDateString(LocalDate.now());

    List<OodiTeacherCourse> courses = oodiRestClient.getTeacherCourses("123", sinceDateString);
    List<OodiTeacherCourse> cachedCourses = oodiRestClient.getTeacherCourses("123", sinceDateString);

    assertThat(cachedCourses).isSameAs(courses);
}

From source file:agendapoo.View.FrmCadastroAtividade.java

private boolean isOldTime(LocalDate data, LocalTime end) {
    Period p = Period.between(data, LocalDate.now());
    if (p.getDays() > 0)
        return true;
    else if (p.getDays() == 0) {
        return end.isBefore(LocalTime.now());
    }/*from   w  ww.  j a  v a  2 s .c  om*/
    return false;
}

From source file:com.qq.tars.service.monitor.TARSStatMonitorCondition.java

public TARSStatMonitorCondition(HttpServletRequest request) {
    thedate = StringUtils.trimToNull(request.getParameter("thedate"));
    predate = StringUtils.trimToNull(request.getParameter("predate"));
    theshowtime = StringUtils.trimToNull(request.getParameter("theshowtime"));
    preshowtime = StringUtils.trimToNull(request.getParameter("preshowtime"));

    masterName = StringUtils.trimToNull(request.getParameter("master_name"));
    slaveName = StringUtils.trimToNull(request.getParameter("slave_name"));
    interfaceName = StringUtils.trimToNull(request.getParameter("interface_name"));
    masterIp = StringUtils.trimToNull(request.getParameter("master_ip"));
    slaveIp = StringUtils.trimToNull(request.getParameter("slave_ip"));

    groupBy = StringUtils.trimToNull(request.getParameter("group_by"));

    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
    if (null == thedate) {
        thedate = LocalDate.now().format(formatter);
    }//from  w  w w .  j  a v  a2 s  . c  om
    if (null == predate) {
        predate = LocalDate.parse(thedate, formatter).plusDays(-1).format(formatter);
    }
    if (null == theshowtime) {
        theshowtime = "0000";
    }
    if (null == preshowtime) {
        preshowtime = "2360";
    }
}

From source file:io.curly.artifact.model.Artifact.java

public Artifact(String id) {
    this.id = id;
    this.author = "";
    this.name = "";
    this.homePage = "";
    this.githubPage = "";
    this.description = "";
    this.languages = new HashSet<>(0);
    this.tags = new HashSet<>(0);
    this.category = new Category();
    this.incubation = LocalDate.now().toString();
    this.owner = "";
}

From source file:org.silverpeas.core.index.indexing.model.RepositoryIndexer.java

public void addPath(Path path, String creatorId) {
    performPath(path, LocalDate.now(), creatorId, ADD_ACTION);
}

From source file:io.gravitee.repository.elasticsearch.monitoring.ElasticMonitoringRepository.java

@Override
public MonitoringResponse query(final String gatewayId) {
    final String suffixDay = LocalDate.now().format(DateTimeFormatter.ofPattern("yyyy.MM.dd"));

    final SearchRequestBuilder monitor = client.prepareSearch("gravitee-" + suffixDay).setTypes("monitor")
            .setQuery(boolQuery().must(termQuery(FIELD_GATEWAY_NAME, gatewayId)))
            .setSearchType(SearchType.QUERY_THEN_FETCH).addSort(FIELD_TIMESTAMP, SortOrder.DESC).setSize(1);

    final SearchResponse searchResponse = monitor.get();
    final SearchHits hits = searchResponse.getHits();
    if (hits != null && hits.getHits().length > 0) {
        return convert(hits.getHits()[0].getSource());
    }/*from w  ww.  ja v a  2s  .com*/
    return null;
}

From source file:br.com.elotech.karina.service.impl.PushServiceBlueMixTest.java

private List<License> createLicenseList() {

    final License license1 = License.builder().cliente(1).code("licenseCode1").date(LocalDate.now())
            .module(Module.ACAO_SOCIAL).name("licenseName1").build();

    final License license2 = License.builder().cliente(1).code("licenseCode2").date(LocalDate.now())
            .module(Module.AGUA_ESGOTO).name("licenseName2").build();

    return Arrays.asList(license1, license2);
}

From source file:org.wallride.job.UpdatePostViewsItemReader.java

@Override
protected void doReadPage() {
    if (results == null) {
        results = new CopyOnWriteArrayList<>();
    } else {// ww w .j a  v  a2s  . c o m
        results.clear();
    }

    Blog blog = blogService.getBlogById(Blog.DEFAULT_ID);
    GoogleAnalytics googleAnalytics = blog.getGoogleAnalytics();
    if (googleAnalytics == null) {
        logger.warn("Configuration of Google Analytics can not be found");
        return;
    }

    Analytics analytics = GoogleAnalyticsUtils.buildClient(googleAnalytics);

    try {
        LocalDate now = LocalDate.now();
        DateTimeFormatter dateTimeFormatter = DateTimeFormatter.ofPattern("yyyy-MM-dd");
        Analytics.Data.Ga.Get request = analytics.data().ga()
                .get(googleAnalytics.getProfileId(), now.minusYears(1).format(dateTimeFormatter),
                        now.format(dateTimeFormatter), "ga:pageViews")
                //                  .setDimensions(String.format("ga:dimension%d", googleAnalytics.getCustomDimensionIndex()))
                //                  .setSort(String.format("-ga:dimension%d", googleAnalytics.getCustomDimensionIndex()))
                .setDimensions(String.format("ga:pagePath", googleAnalytics.getCustomDimensionIndex()))
                .setSort(String.format("-ga:pageViews", googleAnalytics.getCustomDimensionIndex()))
                .setStartIndex(getPage() * getPageSize() + 1).setMaxResults(getPageSize());

        logger.info(request.toString());
        final GaData gaData = request.execute();
        if (CollectionUtils.isEmpty(gaData.getRows())) {
            return;
        }

        results.addAll(gaData.getRows());
    } catch (IOException e) {
        logger.warn("Failed to synchronize with Google Analytics", e);
        throw new GoogleAnalyticsException(e);
    }

    //      logger.info("Synchronization to google analytics is now COMPLETE. {} posts updated.", count);
}

From source file:pl.java.scalatech.generator.RandomPersonService.java

public LocalDate generateBirthDate() {
    return LocalDate.now().minus(16l, ChronoUnit.YEARS).minus(random.nextInt(365 * 50), ChronoUnit.DAYS);
}