Java Year Month getDate(int year, int month, int day)

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

Description

get Date

License

Apache License

Parameter

Parameter Description
year a year
month a month (between 1 eand 12)
day a day in <code>month</code> (between 1 and 31)

Return

a new date for the given day/month/year

Declaration

public static Date getDate(int year, int month, int day) 

Method Source Code

//package com.java2s;
//License from project: Apache License 

import java.util.*;

public class Main {
    /**//from  w  w  w .ja  v a  2s .co  m
     * @param year  a year
     * @param month a month (between 1 eand 12)
     * @param day   a day in <code>month</code> (between 1 and 31)
     * @return a new date for the given day/month/year
     */
    public static Date getDate(int year, int month, int day) {
        return getDate(year, month, day, 0, 0, 0);
    }

    /**
     * @param year  a year
     * @param month a month (between 1 eand 12)
     * @param day   a day in <code>month</code> (between 1 and 31)
     * @param hour an hour (between 0 and 23)
     * @param minute a minute (between 0 and 60)
     * @param second a secode (between 0 and 60)
     * @return a new date for the given day/month/year hour:minute:second
     */
    public static Date getDate(int year, int month, int day, int hour, int minute, int second) {
        Calendar c = Calendar.getInstance();
        c.set(year, month - 1, day, hour, minute, second);
        c.set(Calendar.MILLISECOND, 0);
        return c.getTime();
    }
}

Related

  1. getAddedDate(Date date, int addYear, int addMonth, int addDay, int addHour, int addMinute, int addSecond)
  2. getAllDate(String year_month)
  3. getBeginEndDayOfMonth(String yearMonthString)
  4. getCurrentYearMonthDay()
  5. getCurYearMonth()
  6. getDate(int year, int month, int day, int hour, int minute)
  7. getDaysOfMonth(String year, String month)
  8. getEndDateOfMonth(int year, int month)
  9. getFirstDay(String yearMonthStr, int range)