Example usage for org.joda.time LocalDate now

List of usage examples for org.joda.time LocalDate now

Introduction

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

Prototype

public static LocalDate now() 

Source Link

Document

Obtains a LocalDate set to the current system millisecond time using ISOChronology in the default time zone.

Usage

From source file:de.appsolve.padelcampus.utils.RankingUtil.java

public List<Ranking> getRankedParticipants(Event model) {
    List<Ranking> ranking = new ArrayList<>();
    if (!model.getParticipants().isEmpty()) {
        Participant firstParticipant = model.getParticipants().iterator().next();
        if (firstParticipant instanceof Player) {
            ranking = getPlayerRanking(model.getGender(), model.getPlayers(), LocalDate.now());
        } else if (firstParticipant instanceof Team) {
            List<Team> teams = new ArrayList<>();
            for (Participant p : model.getParticipants()) {
                Team team = (Team) p;/*from   ww  w  .j av a  2 s .c o m*/
                teams.add(teamDAO.findByIdFetchWithPlayers(team.getId()));
            }
            ranking = getTeamRanking(model.getGender(), teams, LocalDate.now());
        }
    }
    Collections.sort(ranking);
    return ranking;
}

From source file:de.appsolve.padelcampus.utils.RankingUtil.java

private List<Ranking> getRanking(List<Game> games, Gender gender, LocalDate date) {
    if (date == null) {
        date = LocalDate.now();
    }// w  w  w  .j av a  2 s.  c  o m
    List<Ranking> rankings = new ArrayList<>();
    Set<Game> sortedGames = new TreeSet<>(new GameByStartDateComparator());
    sortedGames.addAll(games);
    for (Game game : sortedGames) {
        Set<Participant> participants = game.getParticipants();
        if (participants.size() != 2) {
            LOG.warn("Skipping game " + game + " as it does not have 2 participants");
            continue;
        }
        if (game.getGameSets().isEmpty()) {
            LOG.debug("Skipping game " + game + " as no game sets have been played");
            continue;
        }

        Iterator<Participant> iterator = participants.iterator();
        Participant p1 = iterator.next();
        Participant p2 = iterator.next();

        if (p1 instanceof Team && p2 instanceof Team) {
            updateRanking(rankings, game, gender, (Team) p1, (Team) p2, date);
        } else {
            updateRanking(rankings, game, gender, p1, p2, date);
        }
    }
    Collections.sort(rankings);
    return rankings;
}

From source file:de.dreier.mytargets.features.settings.DatePreference.java

License:Open Source License

@Override
protected void onSetInitialValue(boolean restoreValue, Object defaultValue) {
    String value;/*from w  ww  .j av  a2  s  . com*/
    if (restoreValue) {
        if (defaultValue == null) {
            value = getPersistedString(LocalDate.now().toString());
        } else {
            value = getPersistedString(defaultValue.toString());
        }
    } else {
        value = defaultValue.toString();
    }

    date = LocalDate.parse(value);
}

From source file:de.dreier.mytargets.features.settings.SettingsManager.java

License:Open Source License

public static int getProfileAge() {
    final LocalDate birthDay = getProfileBirthDay();
    if (birthDay == null) {
        return -1;
    }/* w w  w  .j  av a  2 s . com*/
    return Years.yearsBetween(birthDay, LocalDate.now()).getYears();
}

From source file:de.iteratec.iteraplan.businesslogic.exchange.timeseriesExcel.importer.TimeseriesExcelImporter.java

License:Open Source License

/**
 * Creates an ExcelTimeseriesExporter for the given workbook.
 *///  w w  w  .  ja v a 2s.  c o  m
public TimeseriesExcelImporter(AttributeTypeService atService, BuildingBlockServiceLocator bbServiceLocator,
        TimeseriesService timeseriesService) {
    this.atService = atService;
    this.bbServiceLocator = bbServiceLocator;
    this.timeseriesService = timeseriesService;
    this.now = LocalDate.now();
}

From source file:de.iteratec.iteraplan.model.attribute.Timeseries.java

License:Open Source License

public void validate() {
    LocalDate now = LocalDate.now();
    for (LocalDate entryDate : values.keySet()) {
        if (now.isBefore(entryDate)) {
            throw new IteraplanBusinessException(IteraplanErrorMessages.TIMESERIES_INVALID_FUTURE_DATE);
        }/*from  w w w .  j  ava 2  s  .c om*/
    }
}

From source file:de.thb.ue.backend.service.ParticipantService.java

License:Apache License

@Override
public List<Participant> add(int amount, Evaluation evaluation)
        throws EvaluationException, ParticipantException {
    List<Participant> createdParticipants = new ArrayList<>(amount);
    List<BufferedImage> qrcs = new ArrayList<>(amount);
    for (int i = 0; i < amount; i++) {
        String voteToken = UUID.randomUUID().toString();
        createdParticipants.add(new Participant(evaluation, false, voteToken, ""));
        try {//  w  w w . j  a  v  a2 s. c om
            qrcs.add(QRCGeneration.generateQRC(
                    "{\"voteToken\":\"" + voteToken + "\",\"host\":\"" + hostadress + "\"}",
                    QRCGeneration.SIZE_SMALL, ErrorCorrectionLevel.Q, QRCGeneration.ENCODING_UTF_8));
        } catch (WriterException | IOException e) {
            throw new ParticipantException(ParticipantException.ERROR_CREATING_QRC_PDF, e.getMessage());
        }
    }
    participantRepo.save(createdParticipants);
    File workingDirectory = new File(
            (workingDirectoryPath.isEmpty() ? "" : (workingDirectoryPath + File.separatorChar))
                    + evaluation.getUid());

    if (!workingDirectory.exists()) {
        try {
            FileUtils.forceMkdir(workingDirectory);
        } catch (IOException e) {
            log.error("Can't create directory for " + evaluation.getUid());
        }
    }

    PDFGeneration.createQRCPDF(qrcs, evaluation.getUid(), evaluation.getSubject().getName(),
            evaluation.getSemesterType(), LocalDate.now().getYear(), workingDirectory);
    return createdParticipants;
}

From source file:de.tshw.worktracker.controller.WorkTrackerController.java

License:MIT License

private void findTodaysEntries() {
    List<WorkLogEntry> entries = workLogEntryDAO.findByDay(LocalDate.now());
    entries.forEach(workTracker::addWorkLogEntry);

}

From source file:de.tshw.worktracker.view.TimeEntriesTableModel.java

License:MIT License

public String update(WorkTracker workTracker) {
    int oldProjectCount = elapsedTimes.size();
    HashMap<Project, MutablePeriod> newTimes = new HashMap<>();
    for (Project p : workTracker.getProjects()) {
        newTimes.put(p, new MutablePeriod());
    }/* ww w  .j  a  va2s. co  m*/
    MutablePeriod totalTimeToday = new MutablePeriod();
    for (WorkLogEntry entry : workTracker.getTodaysWorkLogEntries()) {
        if (!newTimes.containsKey(entry.getProject())) {
            newTimes.put(entry.getProject(), new MutablePeriod());
        }
        if (entry.getStartTime().toLocalDate().toDateTimeAtStartOfDay()
                .equals(LocalDate.now().toDateTimeAtStartOfDay())) {
            newTimes.get(entry.getProject()).add(entry.getTimeElapsed());
            if (!entry.getProject().equals(workTracker.getPauseProject())) {
                totalTimeToday.add(entry.getTimeElapsed());
            }
        }
    }
    WorkLogEntry entry = workTracker.getCurrentLogEntry();
    Period period = new Period(entry.getStartTime(), LocalDateTime.now());
    newTimes.get(entry.getProject()).add(period);
    if (!entry.getProject().equals(workTracker.getPauseProject())) {
        totalTimeToday.add(period);
    }

    for (Project p : newTimes.keySet()) {
        elapsedTimes.put(p, newTimes.get(p).toPeriod());
    }

    this.totalTimeElapsedToday = totalTimeToday.toPeriod();
    if (oldProjectCount == elapsedTimes.size()) {
        this.fireTableRowsUpdated(0, elapsedTimes.size());
    } else {
        this.fireTableDataChanged();
    }

    return periodFormatter.print(this.totalTimeElapsedToday.normalizedStandard());
}

From source file:dom.simple.AlumnoRepositorio.java

License:Open Source License

public String validateCreate(String nombre, String apellido, E_sexo sexo, int dni, LocalDate nacimiento,
        E_nacionalidad nacionalidad, E_localidades localidad, String calle, int numero, String piso,
        String departamento, String telefono) {
    List<Alumno> dniAlumno = container
            .allMatches((new QueryDefault<Alumno>(Alumno.class, "findByDni", "dni", dni)));
    if (!dniAlumno.isEmpty()) {
        return "El nmero de dni ya existe";
    }/*from   ww  w  .j a  v a 2s .  c  o m*/
    if (nacimiento.isAfter(LocalDate.now())) {
        return "La fecha de nacimiento debe ser menor al da actual";
    }
    return null;

}