is Month First Day - Java java.util

Java examples for java.util:Month

Description

is Month 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(isMonthFirstDay(date));
    }/*from   w  ww. j ava  2  s .  c  o  m*/
    
    public static Boolean isMonthFirstDay(Date date) {
        return sf.format(date)
                .equals(CalendarUtil.getFirstDayOfMonth(date));
    }
    
    public static String getFirstDayOfMonth(Date date) {
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-01");
        return sf.format(date);
    }
}

Related Tutorials