Java Year Month getYearMonthDay(final int year, final int month, final int day)

Here you can find the source of getYearMonthDay(final int year, final int month, final int day)

Description

Return normalized year month day date (desired day in month at 00:00:00.000 pm)

License

Open Source License

Parameter

Parameter Description
year a parameter
month a parameter
day a parameter

Declaration

public static Date getYearMonthDay(final int year, final int month, final int day) 

Method Source Code

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

import java.util.Calendar;

import java.util.Date;

public class Main {
    /**//from  w  ww  .  j a  v a 2s . c o m
     * Return normalized year month day date (desired day in month at 00:00:00.000
     * pm)
     * 
     * @param year
     * @param month
     * @param day
     * @return
     */
    public static Date getYearMonthDay(final int year, final int month, final int day) {
        final Calendar calendar = Calendar.getInstance();

        calendar.set(Calendar.YEAR, year);
        calendar.set(Calendar.MONTH, month - 1);
        calendar.set(Calendar.DAY_OF_MONTH, day);

        // normalize time to 00:00:00.000 pm
        calendar.set(Calendar.HOUR_OF_DAY, 0);
        calendar.set(Calendar.MINUTE, 0);
        calendar.set(Calendar.SECOND, 0);
        calendar.set(Calendar.MILLISECOND, 0);

        return calendar.getTime();
    }
}

Related

  1. getYearMonth(String year)
  2. getYearMonthDate()
  3. getYearMonthDateByMisSecond(long misSecond)
  4. getYearMonthDay()
  5. getYearMonthDay(Date date)
  6. getYearMonthList(int year)
  7. getYearMonths(List time)
  8. getYearMonthStr(Date parseDate)
  9. getYearMonthString(Date date)