Friday, February 13, 2026
HomeLanguagesJavaTemporalAdjusters firstDayOfNextYear() method in Java with Examples

TemporalAdjusters firstDayOfNextYear() method in Java with Examples

The firstDayOfNextYear() method of a TemporalAdjusters class is used to return the “first day of next year” TemporalAdjuster object, which returns a new Date object set to the first day of the next year.

Syntax:

public static TemporalAdjuster firstDayOfNextYear()

Parameters: This method accepts nothing.

Return value: This method returns the first day of next year adjuster, not null.

Below programs illustrate the TemporalAdjusters.firstDayOfNextYear() method:
Program 1:




// Java program to demonstrate
// TemporalAdjusters.firstDayOfNextYear()
  
import java.time.LocalDate;
import java.time.temporal.*;
  
public class GFG {
    public static void main(String[] args)
    {
  
        // get TemporalAdjuster with first day
        // of next year adjuster
        TemporalAdjuster temporalAdjuster
            = TemporalAdjusters.firstDayOfNextYear();
  
        // using adjuster for local date-time
        LocalDate localDate
            = LocalDate.of(2020, 05, 11);
        LocalDate firstDayOfNextYear
            = localDate.with(temporalAdjuster);
  
        // print
        System.out.println("First day of next "
                           + "year for localdate "
                           + localDate +": "
                           + firstDayOfNextYear);
    }
}


Output:

First day of next year for localdate 2020-05-11: 2021-01-01

Program 2:




// Java program to demonstrate
// TemporalAdjusters.firstDayOfNextYear() method
  
import java.time.LocalDate;
import java.time.temporal.TemporalAdjuster;
import java.time.temporal.TemporalAdjusters;
  
public class GFG {
    public static void main(String[] args)
    {
  
        // get TemporalAdjuster with first day
        // of next year adjuster
        TemporalAdjuster temporalAdjuster
            = TemporalAdjusters
                  .firstDayOfNextYear();
  
        // using adjuster for local date-time
        LocalDate localDate
            = LocalDate.of(2010, 12, 29);
        LocalDate firstDayOfNextYear
            = localDate.with(temporalAdjuster);
  
        // print
        System.out.println("First day of next "
                           + "year for localdate :"
                           + localDate +": "
                           + firstDayOfNextYear);
    }
}


Output:

First day of next year for localdate :2010-12-29: 2011-01-01

References: https://docs.oracle.com/javase/10/docs/api/java/time/format/TemporalAdjusters.html

RELATED ARTICLES

1 COMMENT

Most Popular

Dominic
32499 POSTS0 COMMENTS
Milvus
128 POSTS0 COMMENTS
Nango Kala
6878 POSTS0 COMMENTS
Nicole Veronica
11999 POSTS0 COMMENTS
Nokonwaba Nkukhwana
12092 POSTS0 COMMENTS
Shaida Kate Naidoo
7011 POSTS0 COMMENTS
Ted Musemwa
7248 POSTS0 COMMENTS
Thapelo Manthata
6961 POSTS0 COMMENTS
Umr Jansen
6953 POSTS0 COMMENTS