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:mesclasses.util.FileSaveUtil.java

public static File createBackupFile() {
    FileConfigurationManager conf = FileConfigurationManager.getInstance();
    if (!saveFileExists()) {
        return null;
    }//from  www.  j a  v  a2s .  c o  m
    File bckFile = new File(
            conf.getBackupDir() + File.separator + FileConfigurationManager.DEFAULT_SAVE_FILE_NAME + "_"
                    + LocalDate.now().format(Constants.DATE_FORMATTER) + ".xml");
    try {
        if (bckFile.exists()) {
            bckFile.delete();
        }
        FileUtils.copyFile(getSaveFile(), bckFile);
        LOG.info("Fichier de sauvegarde " + bckFile.getName() + " cr");
    } catch (Exception e) {
        AppLogger.notif("Impossible de crer le fichier de sauvegarde", e);
    }
    File[] bckFiles = new File(conf.getBackupDir()).listFiles();
    if (bckFiles.length >= 8) {
        bckFiles[0].delete();
    }
    return bckFile;
}

From source file:ch.thp.proto.spring.time.stamp.dataloader.TimesheetLoader.java

@Transactional
@Override//from   www .  j  av  a 2 s .c om
public void load() {
    Set<TimesheetEntry> entriesForNed = new HashSet<>();
    entriesForNed.add(new TimesheetEntry(UUID.randomUUID().toString(), LocalDate.now().minusDays(1),
            Duration.ofHours(4),
            "read something about genealogy. made a comment about the strange color of geoffreys baratheons hair."));
    entriesForNed.add(new TimesheetEntry(UUID.randomUUID().toString(), LocalDate.now().minusDays(1),
            Duration.ofHours(2), "inspected the wall. still white"));
    entriesForNed.add(new TimesheetEntry(UUID.randomUUID().toString(), LocalDate.now().minusDays(1),
            Duration.ofHours(2), "lost my head about something"));
    Timesheet sheetNed = new Timesheet(new TimesheetId(), USER_ID_NED, 24d, 0.8d, LocalDate.now().minusDays(1),
            entriesForNed);

    Set<TimesheetEntry> entriesForHeisenberg = new HashSet<>();
    entriesForHeisenberg.add(new TimesheetEntry(UUID.randomUUID().toString(), LocalDate.now().minusDays(1),
            Duration.ofHours(8), "still cooking, what are you expecting?"));
    entriesForHeisenberg.add(new TimesheetEntry(UUID.randomUUID().toString(), LocalDate.now().minusDays(2),
            Duration.ofHours(8), "still cooking"));
    entriesForHeisenberg.add(new TimesheetEntry(UUID.randomUUID().toString(), LocalDate.now().minusDays(3),
            Duration.ofHours(8), "cooking"));
    Timesheet sheetHeisenberg = new Timesheet(new TimesheetId(), USER_ID_HEISENBERG, 100, 1.0d,
            LocalDate.now().minusDays(3), entriesForHeisenberg);

    Set<TimesheetEntry> entriesForDon = new HashSet<>();
    entriesForDon.add(new TimesheetEntry(UUID.randomUUID().toString(), LocalDate.now().minusDays(1),
            Duration.ofHours(8), "made a witty comment about the usefullness of my minions"));
    entriesForDon.add(new TimesheetEntry(UUID.randomUUID().toString(), LocalDate.now().minusDays(2),
            Duration.ofHours(4), "fighting with betty"));
    entriesForDon.add(new TimesheetEntry(UUID.randomUUID().toString(), LocalDate.now().minusDays(2),
            Duration.ofHours(10), "made overtime. a lot"));
    Timesheet sheetDon = new Timesheet(new TimesheetId(), USER_ID_DON, 100, 1.0d, LocalDate.now().minusDays(2),
            entriesForDon);

    em.persist(sheetNed);
    em.persist(sheetHeisenberg);
    em.persist(sheetDon);
}

From source file:example.springdata.cassandra.java8.Jsr310IntegrationTests.java

@Test
public void findOneByJsr310Types() {

    Order order = new Order("42", LocalDate.now(), ZoneId.systemDefault());

    repository.save(order);//from  www. ja v  a  2  s  .  c o  m

    assertThat(repository.findOrderByOrderDateAndZoneId(order.getOrderDate(), order.getZoneId()),
            is(equalTo(order)));
}

From source file:gov.ca.cwds.cals.web.rest.rfa.TrackingTest.java

@Test
public void updateTest() throws Exception {
    RFA1aFormDTO form = createRfa1a();//from   w  w w.  ja v  a 2s  .  c  om
    Response trackingResponse = createTracking(form);
    TrackingDTO tracking = trackingResponse.readEntity(TrackingDTO.class);

    String newFacilityName = "New Facility Name";
    tracking.setFacilityName(newFacilityName);
    LocalDate now = LocalDate.now();
    getFirstFamilyDocumentsItem(tracking).setReceivedDate(now);
    TrackingDTO putTrackingResponse = updateTracking(tracking).readEntity(TrackingDTO.class);

    Assert.assertEquals(newFacilityName, putTrackingResponse.getFacilityName());
    Assert.assertEquals(now, getFirstFamilyDocumentsItem(putTrackingResponse).getReceivedDate());
    Assert.assertNotNull(putTrackingResponse.getCreateUserId());
    Assert.assertNotNull(putTrackingResponse.getUpdateUserId());
    Assert.assertNotNull(putTrackingResponse.getCreateDateTime());
    Assert.assertNotNull(putTrackingResponse.getUpdateDateTime());

    Response response = updateTracking(-1L, tracking);
    Assert.assertEquals(HttpStatus.SC_BAD_REQUEST, response.getStatus());
}

From source file:se.inera.intyg.intygstjanst.persistence.model.dao.impl.SjukfallCertificateDaoImpl.java

@Override
public List<SjukfallCertificate> findActiveSjukfallCertificateForCareUnits(List<String> careUnitHsaIds) {
    String today = LocalDate.now().format(DateTimeFormatter.ISO_DATE);

    // First, get personnummer for all patients having a currently ongoing intyg.
    List<String> personNummerList = entityManager
            .createQuery("SELECT DISTINCT sc.civicRegistrationNumber FROM SjukfallCertificate sc JOIN "
                    + "sc.sjukfallCertificateWorkCapacity scwc WHERE "
                    + "    sc.careUnitId IN (:careUnitHsaId) " + "AND scwc.fromDate <= :today "
                    + "AND scwc.toDate >= :today " + "AND sc.deleted = FALSE "
                    + "ORDER BY sc.civicRegistrationNumber", String.class)

            .setParameter("careUnitHsaId", careUnitHsaIds).setParameter("today", today).getResultList();

    if (LOG.isDebugEnabled()) {
        LOG.debug("Get personnr with active intyg on enhet {} (with mottagningar) returned {} items.",
                careUnitHsaIds, personNummerList.size());
    }/*from  ww  w .ja va  2 s.  c om*/

    // if no personnummer found, return empty list
    if (personNummerList.size() == 0) {
        return new ArrayList<>();
    }

    // Then, fetch all SjukfallCertificates for these persons on the designated units.
    List<SjukfallCertificate> resultList = entityManager
            .createQuery("SELECT DISTINCT sc FROM SjukfallCertificate sc "
                    + "JOIN FETCH sc.sjukfallCertificateWorkCapacity scwc "
                    + "WHERE sc.civicRegistrationNumber IN (:personNummerList) "
                    + "AND sc.careUnitId IN (:careUnitHsaIds) " + "AND sc.deleted = FALSE "
                    + "ORDER BY sc.civicRegistrationNumber", SjukfallCertificate.class)

            .setParameter("careUnitHsaIds", careUnitHsaIds).setParameter("personNummerList", personNummerList)
            .getResultList();

    if (LOG.isDebugEnabled()) {
        LOG.debug("Read {} SjukfallCertificate for belonging to unit {}", resultList.size(), careUnitHsaIds);
    }
    return resultList;
}

From source file:io.curly.advisor.model.Review.java

public Review(String content, String artifact, String owner, String title, UserInfo userInfo, BigDecimal rate) {
    this.content = content;
    this.artifact = artifact;
    this.owner = owner;
    this.title = title;
    this.userInfo = userInfo;
    this.rate = fixPrecision(rate);
    this.publishDate = LocalDate.now().toString();
}

From source file:example.complete.Customer.java

public int getAge() {
    return Period.between(birthday, LocalDate.now()).getYears();
}

From source file:fi.helsinki.opintoni.service.CourseService.java

public List<CourseDto> getTeacherCourses(String teacherNumber, Locale locale) {
    return oodiClient.getTeacherCourses(teacherNumber, DateTimeUtil.getSemesterStartDateString(LocalDate.now()))
            .stream().map(c -> courseConverter.toDto(c, locale)).collect(Collectors.toList());
}

From source file:ch.algotrader.dao.TransactionDaoImpl.java

@Override
public List<Transaction> findDailyTransactions() {

    LocalDate today = LocalDate.now();
    return find("Transaction.findDailyTransactions", QueryType.BY_NAME,
            new NamedParam("curdate", DateTimeLegacy.toLocalDate(today)));
}

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

public TARSPropertyMonitorCondition(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"));
    masterIp = StringUtils.trimToNull(request.getParameter("master_ip"));
    propertyName = StringUtils.trimToNull(request.getParameter("property_name"));
    policy = StringUtils.trimToNull(request.getParameter("policy"));

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

    DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyyMMdd");
    if (null == thedate) {
        thedate = LocalDate.now().format(formatter);
    }/*from www .  j  a  v a 2 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";
    }
}