PlainDate input = SystemClock.inLocalView().today(); // using system timezone Weekday weekday = Weekday.SUNDAY; PlainDate adjusted = input.with(PlainDate.WEEKDAY_IN_MONTH.setToThird(weekday)); boolean isThirdSundayInMonth = input.equals(adjusted);
@Override public boolean equals(Object obj) { if (this == obj) { return true; } else if (obj instanceof PlainTimestamp) { PlainTimestamp that = (PlainTimestamp) obj; return (this.date.equals(that.date) && this.time.equals(that.time)); } else { return false; } }
@Override public boolean equals(Object obj) { if (super.equals(obj)) { RecurrentDateIntervals that = (RecurrentDateIntervals) obj; return (this.ref.equals(that.ref) && this.duration.equals(that.duration)); } return false; }
@Override public boolean isBefore(ChronoInterval<PlainDate> other) { if (other.getStart().isInfinite()) { return false; } PlainDate endA = this.getEnd().getTemporal(); PlainDate startB = other.getStart().getTemporal(); if (other.getStart().isOpen()) { if (startB.equals(PlainDate.axis().getMaximum())) { return true; } startB = startB.plus(1, CalendarUnit.DAYS); } return endA.isBefore(startB); }
@Override public boolean contains(ChronoInterval<PlainDate> other) { if (!other.isFinite()) { return false; } PlainDate startA = this.getStart().getTemporal(); PlainDate startB = other.getStart().getTemporal(); if (other.getStart().isOpen()) { if (startB.equals(PlainDate.axis().getMaximum())) { return false; } startB = startB.plus(1, CalendarUnit.DAYS); } if (startA.isAfter(startB)) { return false; } PlainDate endA = this.getEnd().getTemporal(); PlainDate endB = other.getEnd().getTemporal(); if (other.getEnd().isOpen()) { if (startB.isSimultaneous(endB)) { return !startB.isAfter(endA); } else if (endB.equals(PlainDate.axis().getMinimum())) { return false; } endB = endB.minus(1, CalendarUnit.DAYS); } return !endA.isBefore(endB); }
PlainDate d1 = start.getCalendarDate(); PlainDate d2 = end.getCalendarDate(); if (!d1.equals(d2)) { DateInterval.getEndPrinter(dateStyle, d1, d2).print(d2, buffer);
PlainDate d2 = tsp2.getCalendarDate(); if (!d1.equals(d2)) { DateInterval.getEndPrinter(dateStyle, d1, d2).print(d2, buffer);