Java Date to Month getMonthStart(Date date)

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

Description

get Month Start

License

Open Source License

Declaration

public static Date getMonthStart(Date date) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

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

public class Main {

    public static Date getMonthStart(Date date) {
        if (date == null) {
            return null;
        }/*from  ww w  .  j  a v  a  2s .  c  o  m*/

        Calendar cal = Calendar.getInstance();
        cal.setTime(date);
        cal.set(Calendar.DAY_OF_MONTH, 1);
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.SECOND, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.MILLISECOND, 0);
        return cal.getTime();
    }

    public static long getTime(Date date) {
        return date.getTime();
    }
}

Related

  1. getMonthOfYear(Date date)
  2. getMonthOfYear(Date dt)
  3. getMonthOfYear(final Date date)
  4. getMonthRate(Date date, boolean moveIn)
  5. getMonths(Date date1, Date date2)
  6. getMonthStart(Date date)
  7. getMonthStartDay(Date date)
  8. getNextMonth(Date baseDate, int Month)
  9. getNextMonth(Date time)