Java Calendar Month getMonthStart(Calendar cal)

Here you can find the source of getMonthStart(Calendar cal)

Description

get Month Start

License

Open Source License

Declaration

public static Date getMonthStart(Calendar cal) 

Method Source Code

//package com.java2s;

import java.util.Calendar;
import java.util.Date;

public class Main {

    public static Date getMonthStart(Calendar cal) {
        cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.getActualMinimum(Calendar.DAY_OF_MONTH), 0, 0,
                1);//ww  w.  j a  va 2 s  .  c  o  m
        return cal.getTime();
    }

    public static Date getMonthStart(Date date) {
        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        cal.set(cal.get(Calendar.YEAR), cal.get(Calendar.MONTH), cal.getActualMinimum(Calendar.DAY_OF_MONTH), 0, 0,
                0);
        return cal.getTime();
    }
}

Related

  1. getMonth(Calendar calendar)
  2. getMonthBegin(Calendar c)
  3. getMonthBegin(Calendar calendar)
  4. getMonthName(Calendar cal)
  5. getMonthStart(Calendar c)
  6. getMonthStr(Calendar cal)
  7. getNextMonth(Calendar calendar, int month)
  8. getNumDaysInMonth(GregorianCalendar aCalendar)
  9. getStartOfMonth(Date day, Calendar cal)