List of usage examples for java.time LocalDate equals
@Override public boolean equals(Object obj)
From source file:Main.java
public static void main(String[] args) { LocalDate l = LocalDate.now(); System.out.println(l.equals(LocalDate.now())); }
From source file:Main.java
public static void main(String[] argv) { LocalDate date1 = LocalDate.now(); LocalDate date2 = LocalDate.of(date1.getYear(), date1.getMonth(), date1.getDayOfMonth()); if (date1.equals(date2)) { System.out.printf("Today %s and date1 %s are same date %n", date1, date2); }/*from ww w. ja va 2 s . c om*/ }
From source file:Main.java
public static List<LocalDate> getDatesInPeriod(Date startDate, Date endDate) { List<LocalDate> dates = new ArrayList<>(); LocalDate start = toLocalDate(startDate); LocalDate end = toLocalDate(endDate); while (!start.equals(end)) { dates.add(start);/* ww w . ja va 2 s.co m*/ start = start.plusDays(1); } return dates; }
From source file:com.github.drbookings.LocalDates.java
public static boolean isLastDayOfMonth(final LocalDate date) { return date.equals(getLastDayOfMonth(date)); }
From source file:fi.csc.emrex.smp.model.VerificationReply.java
public static VerificationReply verify(Person firstPerson, Person otherPerson, double threshold) { VerificationReply r = new VerificationReply(); if (firstPerson == null || otherPerson == null) { r.setNameVerified(false);// ww w . j a v a 2 s . c o m r.setbDayVerified(false); r.addMessage("Person missing"); return r; } r.setFullNameFromHomeInstitute(firstPerson.getFullName()); r.setFullNameInElmo(otherPerson.getFullName()); r.setHomeInstitute(firstPerson.getHomeOrganizationName()); boolean bdMatch = false; boolean nameMatch = false; int match = 0; LocalDate vbd = firstPerson.getBirthDate(); LocalDate ebd = otherPerson.getBirthDate(); String message = ""; if (ebd == null || vbd == null) { message = "Birthdate not set for " + (ebd == null ? "elmo" : "local") + " person."; r.addMessage(message); log.info(message); } else if (!ebd.equals(vbd)) { message = "Birthdate does not match."; r.addMessage(message); log.info(message); log.info("haka bday " + vbd.toString() + "elmo bday:" + ebd.toString()); } else { bdMatch = true; } double score = 0; score += levenshteinDistance(firstPerson.getLastName(), otherPerson.getLastName()); score += levenshteinDistance(firstPerson.getFirstName(), otherPerson.getFirstName()); double length = 0; String fullname = firstPerson.getFullName(); if (fullname != null) { length = fullname.length(); } else { length = 1; } double ratio = score / length; r.addMessage("Error ratio " + ratio + " based on Levenshtein check on name."); if (ratio > threshold) { r.addMessage("Ratio over threshold " + threshold); } else { nameMatch = true; } r.setNameVerified(nameMatch); r.setbDayVerified(bdMatch); return r; }
From source file:com.romeikat.datamessie.core.base.ui.panel.DocumentsFilterPanel.java
public static String formatLocalDate(final LocalDate localDate) { // No date corresponds to 0 if (localDate == null) { return "0"; }//from www. j a v a2s . c om // Today corresponds to no date final LocalDate today = LocalDate.now(); if (localDate.equals(today)) { return null; } // Date pattern return localDate.format(DateTimeFormatter.ofPattern(DATE_TIME_PATTERN)); }
From source file:de.lgblaumeiser.ptm.analysis.analyzer.ProjectComputer.java
private Collection<Booking> getBookingsForDay(final LocalDate day) { return store.retrieveAll().stream().filter(b -> day.equals(b.getBookingday())).collect(Collectors.toList()); }
From source file:fi.csc.emrex.smp.model.Person.java
public VerificationReply verifiy(Person otherPerson) { //TODO implement verification algorithm; VerificationReply r = new VerificationReply(); r.setFullNameFromHomeInstitute(this.getFullName()); r.setFullNameInElmo(otherPerson.getFullName()); boolean bdMatch = false; boolean nameMatch = false; int match = 0; LocalDate vbd = this.birthDate; LocalDate ebd = otherPerson.getBirthDate(); if (ebd == null || vbd == null) { r.addMessage("Birth date not set for " + (ebd == null ? "elmo" : "local") + " person."); } else if (!ebd.equals(vbd)) { r.addMessage("Birth date does not match."); } else {// w w w . j ava2 s. c o m bdMatch = true; } double score = 0; score += levenshteinDistance(this.getLastName(), otherPerson.getLastName()); score += levenshteinDistance(this.getFirstName(), otherPerson.getFirstName()); double ratio = StringUtils.isNotBlank(this.getFullName()) ? score / this.getFullName().length() : 0.0; r.addMessage("Error ratio " + ratio + " based on Levenshtein check on name."); if (ratio > this.threshold) { r.addMessage("Ratio over threshold " + threshold); } else { nameMatch = true; } r.setVerified(bdMatch && nameMatch); return r; }
From source file:fr.lepellerin.ecole.service.internal.CantineServiceImpl.java
@Override @Transactional(readOnly = true)// w w w . j a va 2 s. com public PlanningDto getDateOuvert(final YearMonth anneeMois, final Famille famille) throws TechnicalException { final Date startDate = Date.from(Instant.from(anneeMois.atDay(1).atStartOfDay(ZoneId.systemDefault()))); final Date endDate = Date.from(Instant.from(anneeMois.atEndOfMonth().atStartOfDay(ZoneId.systemDefault()))); final Activite activite = getCantineActivite(); final LocalDateTime heureH = LocalDateTime.now(); final List<Inscription> icts = this.ictRepository.findByActiviteAndFamille(activite, famille); final PlanningDto planning = new PlanningDto(); icts.forEach(ict -> { planning.getHeaders().add(ict.getIndividu().getPrenom()); final List<Consommation> consos = this.consommationRepository .findByFamilleInscriptionActiviteUniteEtatsPeriode(famille, activite, ict.getGroupe(), Arrays.asList("reservation"), startDate, endDate); final List<Ouverture> ouvertures = this.ouvertureRepository.findByActiviteAndGroupeAndPeriode(activite, ict.getGroupe(), startDate, endDate); ouvertures.forEach(o -> { final LocalDate date = LocalDate.from(((java.sql.Date) o.getDate()).toLocalDate()); final LocalDateTime heureResa = this.getLimiteResaCantine(date); final LigneDto ligne = planning.getOrCreateLigne(date); final CaseDto c = new CaseDto(); c.setDate(date); c.setIndividu(ict.getIndividu()); c.setActivite(o.getActivite()); c.setUnite(o.getUnite()); c.setReservable(heureResa.isAfter(heureH)); final Optional<Consommation> cOpt = consos.stream().filter(conso -> { final LocalDate dateConso = LocalDate.from(((java.sql.Date) conso.getDate()).toLocalDate()); return dateConso.equals(date); }).findAny(); c.setReserve(cOpt.isPresent()); ligne.getCases().add(c); }); }); return planning; }
From source file:com.github.drbookings.ui.controller.UpcomingController.java
private void addEvents(final LocalDate date, final Collection<BookingEntry> upcomingBookings, final Collection<CleaningEntry> upcomingCleanings) { final VBox box = new VBox(4); if (date.equals(LocalDate.now())) { box.getStyleClass().add("first-day"); } else if (date.equals(LocalDate.now().plusDays(1))) { box.getStyleClass().add("second-day"); } else if (date.isAfter(LocalDate.now().plusDays(1))) { box.getStyleClass().add("later"); }/*from w w w . j av a 2 s .c o m*/ if (upcomingBookings.stream().filter(b -> b.isCheckIn() || b.isCheckOut()).collect(Collectors.toList()) .isEmpty() && upcomingCleanings.isEmpty()) { final Text t0 = new Text(getDateString(date)); final Text t1 = new Text(" there are no events."); t0.getStyleClass().add("emphasis"); final TextFlow tf = new TextFlow(); tf.getChildren().addAll(t0, t1); box.getChildren().addAll(tf); } else { final List<CheckInOutDetails> checkInNotes = Collections.synchronizedList(new ArrayList<>()); final List<CheckInOutDetails> checkOutNotes = Collections.synchronizedList(new ArrayList<>()); upcomingBookings.forEach(b -> { if (b.isCheckIn()) { String note = ""; if (b.getElement().getCheckInNote() != null) { note = b.getElement().getCheckInNote(); } if (b.getElement().getSpecialRequestNote() != null) { note = note + "\n" + b.getElement().getSpecialRequestNote(); } checkInNotes.add(new CheckInOutDetails(b.getRoom().getName(), b.getElement().getBookingOrigin().getName(), note)); } else if (b.isCheckOut()) { checkOutNotes.add(new CheckInOutDetails(b.getRoom().getName(), b.getElement().getBookingOrigin().getName(), b.getElement().getCheckOutNote())); } }); Collections.sort(checkInNotes); Collections.sort(checkOutNotes); addGeneralSummary(date, box, checkInNotes); addCheckOutSummary(date, box, checkOutNotes); addCheckOutNotes(date, box, checkOutNotes); addCheckInSummary(date, box, checkInNotes); addCheckInNotes(date, box, checkInNotes); addCleaningSummary(date, box, upcomingCleanings); addCleanings(date, box, upcomingCleanings); } this.box.getChildren().add(box); }