Java examples for java.time:Year
get First Date Of Current Year
//package com.java2s; import java.time.*; import java.time.temporal.TemporalAdjusters; import java.util.Date; public class Main { public static Date getFirstDateOfCurrentYear() { return toDate(LocalDate.now().with( TemporalAdjusters.firstDayOfYear())); }/* w w w.j av a 2s.c o m*/ public static Date toDate(LocalDate date) { Instant instant = date.atStartOfDay() .atZone(ZoneId.systemDefault()).toInstant(); return Date.from(instant); } public static Date toDate(LocalDateTime date) { Instant instant = date.atZone(ZoneId.systemDefault()).toInstant(); return Date.from(instant); } }