Java Day of Month getFirstDayOfMonth(Date date)

Here you can find the source of getFirstDayOfMonth(Date date)

Description

get First Day Of Month

License

Open Source License

Declaration

@SuppressWarnings("deprecation")
    public static Date getFirstDayOfMonth(Date date) 

Method Source Code


//package com.java2s;
import java.util.Calendar;
import java.util.Date;

public class Main {
    @SuppressWarnings("deprecation")
    public static Date getFirstDayOfMonth(Date date) {
        Calendar result = Calendar.getInstance();

        Calendar calendar = Calendar.getInstance();
        calendar.set(Calendar.YEAR, date.getYear() + 1900);
        calendar.set(Calendar.MONTH, date.getMonth());
        calendar.set(Calendar.DATE, date.getDate());

        result.set(Calendar.DATE, calendar.getActualMinimum(Calendar.DATE));
        result.set(Calendar.MONTH, calendar.get(Calendar.MONTH));
        result.set(Calendar.YEAR, calendar.get(Calendar.YEAR));

        return result.getTime();
    }//from w ww . j  a v a  2  s . c  o  m
}

Related

  1. getDayOfMonth(Date date)
  2. getDayOfMonth(Date date)
  3. getDayOfMonth(Date dt)
  4. getDayOfMonth(final Date date)
  5. getFirstDayOfMonth(Date date)
  6. getFirstDayOfMonth(java.util.Date date)
  7. getFirstMiddleDayOfMonth(Date date)
  8. getFistDayOfMonth(Date date)
  9. getFromDate(boolean invoiceSearchFromFirstDayOfMonth)