List of usage examples for java.time LocalDate plusDays
public LocalDate plusDays(long daysToAdd)
From source file:br.ufac.sion.dao.InscricaoFacade.java
private Map<Date, Long> criaMapaVazio(Integer numeroDeDias, LocalDateTime dataInicial) { Map<Date, Long> mapaInicial = new TreeMap<>(); LocalDate dt = dataInicial.toLocalDate(); for (int i = 0; i <= numeroDeDias; i++) { mapaInicial.put(DateConversor.convertLocalDateToDate(dt), 0L); dt = dt.plusDays(1); }/*from w w w. j a v a2s . co m*/ return mapaInicial; }
From source file:com.romeikat.datamessie.core.base.service.DocumentService.java
private LocalDate getNextDownloadedDate(final LocalDate downloadedDate) { // Increase only up to current date final LocalDate now = LocalDate.now(); if (downloadedDate.isAfter(now)) { return null; }//from ww w .j a v a 2 s . co m // Otherwise, go to next date return downloadedDate.plusDays(1); }
From source file:com.romeikat.datamessie.core.base.dao.impl.DocumentDao.java
public List<Document> getForSourceAndDownloaded(final SharedSessionContract ssc, final long sourceId, final LocalDate downloaded) { final LocalDateTime minDownloaded = LocalDateTime.of(downloaded, LocalTime.MIDNIGHT); final LocalDateTime maxDownloaded = LocalDateTime.of(downloaded.plusDays(1), LocalTime.MIDNIGHT); // Query: Document final EntityWithIdQuery<Document> documentQuery = new EntityWithIdQuery<>(Document.class); documentQuery.addRestriction(Restrictions.eq("sourceId", sourceId)); documentQuery.addRestriction(Restrictions.ge("downloaded", minDownloaded)); documentQuery.addRestriction(Restrictions.lt("downloaded", maxDownloaded)); // Done/* w w w .j a v a 2 s.com*/ final List<Document> entities = documentQuery.listObjects(ssc); return entities; }
From source file:com.romeikat.datamessie.core.processing.task.documentProcessing.DocumentsProcessingTask.java
private LocalDate getNextDownloadedDate(final LocalDate downloadedDate) { // If download date is current date (or future), remain at current date final LocalDate now = LocalDate.now(); if (!downloadedDate.isBefore(now)) { return now; }/* ww w . j ava 2s.c o m*/ // Otherwise, go to next date return downloadedDate.plusDays(1); }
From source file:net.resheim.eclipse.timekeeper.ui.views.ExportToClipboard.java
private void append(LocalDate firstDayOfWeek, StringBuilder sb, Object object) { if (object instanceof String) { sb.append("<tr style=\"background: #eeeeee;\"><td>"); sb.append(object);// ww w . j a va 2 s . c om for (int i = 0; i < 7; i++) { sb.append("</td><td style=\"text-align: right; border-left: 1px solid #aaa\">"); LocalDate weekday = firstDayOfWeek.plusDays(i); int seconds = getSum(provider.getFiltered(), weekday, (String) object); if (seconds > 60) { sb.append(DurationFormatUtils.formatDuration(seconds * 1000, "H:mm", true)); } } sb.append("</td></tr>"); } if (object instanceof WeeklySummary) { sb.append("<tr style=\"background: #dedede; border-top: 1px solid #aaa;\"><td>"); sb.append("Daily total"); for (int i = 0; i < 7; i++) { sb.append("</td><td style=\"text-align: right; border-left: 1px solid #aaa\">"); LocalDate weekday = firstDayOfWeek.plusDays(i); int seconds = getSum(provider.getFiltered(), weekday); if (seconds > 60) { sb.append(DurationFormatUtils.formatDuration(seconds * 1000, "H:mm", true)); } } sb.append("</td></tr>"); } if (object instanceof ITask) { sb.append("<tr><td> "); AbstractTask task = (AbstractTask) object; String taskKey = task.getTaskKey(); if (taskKey != null) { sb.append("<a href=\"" + task.getUrl() + "\">"); sb.append(taskKey); sb.append("</a>"); sb.append(": "); } sb.append(task.getSummary()); for (int i = 0; i < 7; i++) { sb.append("</td><td style=\"text-align: right; border-left: 1px solid #aaa\">"); LocalDate weekday = firstDayOfWeek.plusDays(i); int seconds = Activator.getActiveTime(task, weekday); if (seconds > 60) { sb.append(DurationFormatUtils.formatDuration(seconds * 1000, "H:mm", true)); } } sb.append("</td></tr>"); } sb.append(System.lineSeparator()); if (object instanceof String) { Object[] children = provider.getChildren(object); for (Object o : children) { append(firstDayOfWeek, sb, o); } } }
From source file:org.silverpeas.core.workflow.api.user.ReplacementListTest.java
private ReplacementImpl replacement(final String incumbentId, final String substituteId, final LocalDate start, final LocalDate end) throws IllegalAccessException { final ReplacementImpl replacement = new ReplacementImpl(); writeField(replacement, "incumbentId", incumbentId, true); writeField(replacement, "substituteId", substituteId, true); writeField(replacement, "workflowId", "w3", true); writeField(replacement, "period", Period.between(start, end.plusDays(1)), true); return replacement; }
From source file:org.optaplanner.examples.conferencescheduling.persistence.ConferenceSchedulingGenerator.java
private void createTimeslotList(ConferenceSolution solution, int timeslotListSize) { List<Timeslot> timeslotList = new ArrayList<>(timeslotListSize); int timeslotOptionsIndex = 0; LocalDate day = timeslotFirstDay; for (int i = 0; i < timeslotListSize; i++) { Timeslot timeslot = new Timeslot(); timeslot.setId((long) i); if (timeslotOptionsIndex >= timeslotOptions.size()) { timeslotOptionsIndex = 0;/*from w w w . ja va2 s.c om*/ day = day.plusDays(1); } Pair<LocalTime, LocalTime> pair = timeslotOptions.get(timeslotOptionsIndex); timeslot.setStartDateTime(LocalDateTime.of(day, pair.getLeft())); timeslot.setEndDateTime(LocalDateTime.of(day, pair.getRight())); TalkType talkType = timeslot.getDurationInMinutes() >= 120 ? labTalkType : breakoutTalkType; talkType.getCompatibleTimeslotSet().add(timeslot); timeslot.setTalkTypeSet(Collections.singleton(talkType)); timeslotOptionsIndex++; Set<String> tagSet = new LinkedHashSet<>(2); timeslot.setTagSet(tagSet); logger.trace("Created timeslot ({}) with tags ({}).", timeslot, tagSet); timeslotList.add(timeslot); } solution.setTimeslotList(timeslotList); }
From source file:de.jfachwert.rechnung.Rechnungsmonat.java
/** * Diese Methode kann verwendet werden, um den ersten Montag im Monat * zu bestimmen. Dazu ruft man diese Methode einfach mit * {@link DayOfWeek#MONDAY} als Parameter auf. * /* w ww. j av a2s .co m*/ * @param wochentag z.B. {@link DayOfWeek#MONDAY} * @return z.B. erster Arbeitstag * @since 0.6 */ public LocalDate ersterTag(DayOfWeek wochentag) { LocalDate tag = ersterTag(); while (tag.getDayOfWeek() != wochentag) { tag = tag.plusDays(1); } return tag; }
From source file:de.jfachwert.rechnung.Rechnungsmonat.java
/** * Diese Methode liefert den ersten Arbeitstag eines Monats. Allerdings * werden dabei keine Feiertag beruecksichtigt, sondern nur die Wochenende, * die auf einen ersten des Monats fallen, werden berucksichtigt. * /* ww w . ja va 2 s. c o m*/ * @return erster Arbeitstag * @since 0.6 */ public LocalDate ersterArbeitstag() { LocalDate tag = ersterTag(); switch (tag.getDayOfWeek()) { case SATURDAY: return tag.plusDays(2); case SUNDAY: return tag.plusDays(1); default: return tag; } }
From source file:com.github.drbookings.model.data.manager.MainManager.java
private void fillMissing() { final List<LocalDate> dates = new ArrayList<>(uiDataMap.keySet()); Collections.sort(dates);/*w w w . ja v a 2 s .c o m*/ final Collection<LocalDate> toAdd = new HashSet<>(); LocalDate last = null; for (final LocalDate d : dates) { if (last != null) { if (d.equals(last.plusDays(1))) { // ok } else { toAdd.addAll(new DateRange(last.plusDays(1), d.minusDays(1)).toList()); } } last = d; } for (final LocalDate d : toAdd) { addDateBean(new DateBean(d, this)); } }