Java Year Month getStartMonth(int year, int month)

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

Description

get Start Month

License

Open Source License

Declaration

public static Date getStartMonth(int year, int month) 

Method Source Code

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

import java.text.SimpleDateFormat;
import java.util.Calendar;
import java.util.Date;

public class Main {
    public static Date getStartMonth(int year, int month) {
        Calendar calendar = Calendar.getInstance();
        calendar.set(year, month, 1);// w w w. ja  v  a2  s .com
        return getStartDate(calendar.getTime());
    }

    public static Date getStartDate(Date date) {
        if (date == null) {
            return null;
        }

        Calendar cal = Calendar.getInstance();
        cal.setTime(date);

        cal.set(11, 0);
        cal.set(12, 0);
        cal.set(13, 0);
        cal.set(14, 0);

        return cal.getTime();
    }

    public static String getTime(Date dt, String format) {
        SimpleDateFormat st = new SimpleDateFormat(format);
        return st.format(dt);
    }
}

Related

  1. getFirstYearMonth()
  2. getMonthDays(Integer year, Integer month)
  3. getMonthDays(Integer year, Integer month)
  4. getPerMonthByCuttentYear()
  5. getQuarterToYearMonthDay(Integer year, Integer quarter)
  6. getTheLastDayOfTheMonth(int year, int month)
  7. getThisYearMonth()
  8. getThisYearMonth()
  9. getTimeByYearMonth(String yearMonth, String timeZone)