Java Month Day getMonthDay(int year, int month)

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

Description

get Month Day

License

Open Source License

Declaration

public static Date getMonthDay(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 getMonthDay(int year, int month) {
        Calendar cal = Calendar.getInstance();
        cal.set(Calendar.YEAR, year);
        cal.set(Calendar.MONTH, month - 1);
        int lastDay = cal.getActualMaximum(Calendar.DAY_OF_MONTH);
        cal.set(Calendar.DAY_OF_MONTH, lastDay);
        return cal.getTime();
    }/*  w w  w .j  ava 2s . c  o  m*/

    /**
     * Get current time.
     * 
     * @return
     */
    public static String getTime() {
        SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        return dateFormat.format(new Date());
    }
}

Related

  1. getLastMonthLastDate()
  2. getLastMonthLastDay()
  3. getLastMonthLastDay()
  4. getLastMothStart()
  5. GetLastWorkDayofMonth(String strDateStart)
  6. getMonthEndDay(String time)
  7. getMonthEndDay(String yyyy, String mm)
  8. getMonthFirstDay()
  9. getMonthFirstDay()