We would like to know how to get year information.
import java.time.LocalDate; import java.time.Year; /*w ww. ja v a2s . c o m*/ public class Main { public static void main(String[] args) { LocalDate date = LocalDate.of(2014, 2, 15); // 2014-02-15 System.out.println(date.getYear()); // 2014 System.out.println(date.getDayOfYear()); // 46 System.out.println(date.lengthOfYear()); // 365 System.out.println(date.isLeapYear()); // false Year year_2014 = Year.of(2014); System.out.println(year_2014.isLeap()); // false } }
The code above generates the following result.