Java Date Start getStartOfMonth(Date dt)

Here you can find the source of getStartOfMonth(Date dt)

Description

Return the first day of the month from the Date given Hour, minutes, seconds are set to 0:00:00

License

Open Source License

Declaration

public static Date getStartOfMonth(Date dt) 

Method Source Code


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

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

public class Main {
    /**/*from   w w w .  j av  a 2s.c o m*/
     * Return the first day of the month from the Date given Hour, minutes,
     * seconds are set to 0:00:00
     * 
     * @return
     */
    public static Date getStartOfMonth(Date dt) {
        if (dt == null)
            return null;
        GregorianCalendar gc = new GregorianCalendar();
        gc.setTime(dt);
        gc.set(Calendar.DAY_OF_MONTH, 1);
        gc.set(Calendar.HOUR_OF_DAY, 0);
        gc.set(Calendar.MINUTE, 0);
        gc.set(Calendar.SECOND, 0);
        gc.set(Calendar.MILLISECOND, 0);
        return gc.getTime();
    }
}

Related

  1. getStartOfDay(Date date)
  2. getStartOfDay(Date date)
  3. getStartOfDay(Date day)
  4. getStartOfDay(Date day)
  5. getStartOfMonth(Date date)
  6. getStartOfMonth(Date dt)
  7. getStartOfQuarter(Date dt)
  8. getStartTimeByManDay(Date serviceStartTime)
  9. getStartTimeOfDate(Date date)