List of usage examples for java.time Period isNegative
public boolean isNegative()
From source file:Main.java
public static void main(String[] args) { Period p = Period.ofMonths(1); System.out.println(p.isNegative()); }
From source file:Main.java
public static void main(String[] args) { LocalDate firstDate = LocalDate.of(2013, 5, 17); LocalDate secondDate = LocalDate.of(2015, 3, 7); Period period = Period.between(firstDate, secondDate); System.out.println(period);// www. jav a 2 s .c om int days = period.getDays(); // 18 int months = period.getMonths(); // 9 int years = period.getYears(); // 4 boolean isNegative = period.isNegative(); // false }
From source file:Main.java
@Override public LocalDate queryFrom(TemporalAccessor temporal) { LocalDate date = LocalDate.from(temporal); LocalDate currentYearMLKDay = getMartinLutherKingDayForDateInYear(date.getYear()); Period periodToCurrentYearMLKDay = Period.between(date, currentYearMLKDay); if (periodToCurrentYearMLKDay.isNegative() || periodToCurrentYearMLKDay.isZero()) { return getMartinLutherKingDayForDateInYear(date.getYear() + 1); } else {/*from w w w. j a v a2 s. co m*/ return currentYearMLKDay; } }