is Year First Day - Java java.util

Java examples for java.util:Year

Description

is Year First Day

Demo Code


import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Main{
    public static void main(String[] argv) throws Exception{
        Date date = new Date();
        System.out.println(isYearFirstDay(date));
    }/*from ww  w. j  av a 2 s .co  m*/
    
    public static Boolean isYearFirstDay(Date date) {
        return sf.format(date).equals(CalendarUtil.getFirstDayOfYear(date));
    }
    
    public static String getFirstDayOfYear(Date date) {
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-01-01");
        return sf.format(date);
    }
}

Related Tutorials