Java Year Month getFirstDayOfMonth(int year, int month, Integer day)

Here you can find the source of getFirstDayOfMonth(int year, int month, Integer day)

Description

get First Day Of Month

License

Open Source License

Declaration

public static String getFirstDayOfMonth(int year, int month, Integer day) 

Method Source Code


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

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

public class Main {

    public static String getFirstDayOfMonth(int year, int month, Integer day) {

        Calendar cal = Calendar.getInstance();

        cal.set(Calendar.YEAR, year);

        cal.set(Calendar.MONTH, month - 1);
        if (day == null) {
            cal.set(Calendar.DAY_OF_MONTH, cal.getMinimum(Calendar.DATE));
        } else {//from   w ww  . ja v  a 2s. c o  m
            cal.set(Calendar.DAY_OF_MONTH, day);
        }

        StringBuffer sb = new StringBuffer();
        String date = new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime());
        sb.append(date).append(" 00:00");
        return sb.toString();

    }
}

Related

  1. getDaysOfMonth(String year, String month)
  2. getEndDateOfMonth(int year, int month)
  3. getFirstDay(String yearMonthStr, int range)
  4. getFirstDayByMonthWeek(int year, int month, int week)
  5. getFirstDayOfMonth(int year, int month)
  6. getFirstTimeOfDay(int year, int month, int day)
  7. getFirstYearMonth()
  8. getMonthDays(Integer year, Integer month)
  9. getMonthDays(Integer year, Integer month)