Example usage for java.time.temporal TemporalAdjusters lastDayOfYear

List of usage examples for java.time.temporal TemporalAdjusters lastDayOfYear

Introduction

In this page you can find the example usage for java.time.temporal TemporalAdjusters lastDayOfYear.

Prototype

public static TemporalAdjuster lastDayOfYear() 

Source Link

Document

Returns the "last day of year" adjuster, which returns a new date set to the last day of the current year.

Usage

From source file:Main.java

public static void main(String[] args) {
    LocalDate date = LocalDate.of(2014, Month.FEBRUARY, 25); // 2014-02-25

    // last day of 2014 (2014-12-31)
    LocalDate lastDayOfYear = date.with(TemporalAdjusters.lastDayOfYear());

    System.out.println(lastDayOfYear);
}

From source file:Main.java

public static void main(String[] args) {
    LocalDate today = LocalDate.now();

    // Temporal adjusters for adjusting the dates
    System.out.println("First date of this month= " + today.with(TemporalAdjusters.firstDayOfMonth()));
    LocalDate lastDayOfYear = today.with(TemporalAdjusters.lastDayOfYear());
    System.out.println("Last date of this year= " + lastDayOfYear);

    Period period = today.until(lastDayOfYear);
    System.out.println("Period Format= " + period);
    System.out.println("Months remaining in the year= " + period.getMonths());

}