Java Month of Year getMonthStart(int year, int month)

Here you can find the source of getMonthStart(int year, int month)

Description

Get the beginning time of a month

License

Open Source License

Parameter

Parameter Description
year a parameter
month a parameter

Declaration

public static Date getMonthStart(int year, int month) 

Method Source Code


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

public class Main {
    /**//  www.  j  a v  a2  s. c om
     * Get the beginning time of a month
     * 
     * @param year
     * @param month
     * @return
     */
    public static Date getMonthStart(int year, int month) {
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.YEAR, year);
        cal.set(Calendar.MONTH, month);
        cal.set(Calendar.DATE, 1);
        cal.set(Calendar.HOUR_OF_DAY, 0);
        cal.set(Calendar.MINUTE, 0);
        cal.set(Calendar.SECOND, 0);
        return cal.getTime();
    }
}

Related

  1. getMonthDays(Object year, Object month)
  2. getMonthHaveDays(int year, int month)
  3. getMonthOfYear(int m)
  4. getMonthOfYear(long time)
  5. getMonthOfYearFromTimestamp(long ms)
  6. getNextiMonth(Date date, int month)
  7. getNextMonth()
  8. getNextMonth(Calendar aCal)
  9. getNextMonth(Date nowdate, int delay)