Java Date Create createDate(final int day, final int month, final int year)

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

Description

Creates a date from the given components.

License

Open Source License

Parameter

Parameter Description
day the day of the month, 1-31.
month the month, 1-12.
year the year.

Return

a date with the specified settings.

Declaration

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

Method Source Code


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

import java.util.Calendar;
import java.util.Date;

public class Main {
    /**//from   www . jav  a2 s  .c o m
     * Creates a date from the given components.
     *
     * @param day the day of the month, 1-31.
     * @param month the month, 1-12.
     * @param year the year.
     * @return a date with the specified settings.
     */
    public static Date createDate(final int day, final int month, final int year) {
        Calendar cal = Calendar.getInstance();
        cal.clear();

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

        return cal.getTime();
    }
}

Related

  1. castToDate(Object value)
  2. create(int year, int month, int date, TimeZone timeZone)
  3. createDate(final Date date)
  4. createDate(final Date date)
  5. createDate(final int aYear, final int aMonth, final int aDate, final int aHour, final int aMinute, final int aSecond)
  6. createDate(final int month, final int day, final int year)
  7. createDate(final int year, final int month, final int day, final int hour, final int minute, final int second, final int millisecond)
  8. createDate(final int yyyy, final int month, final int day)
  9. createDate(int month, int day)