Java Date Create createDateObject(Integer year, Integer month, Integer dayOfMonth, Integer hourOfDay, Integer minute, Integer second, Integer milissecond)

Here you can find the source of createDateObject(Integer year, Integer month, Integer dayOfMonth, Integer hourOfDay, Integer minute, Integer second, Integer milissecond)

Description

Create a Date object based on default Calendar instance.

License

Open Source License

Parameter

Parameter Description
year a parameter
month a parameter
dayOfMonth a parameter
hourOfDay a parameter
minute a parameter
second a parameter
milissecond a parameter

Declaration

public static Date createDateObject(Integer year, Integer month, Integer dayOfMonth, Integer hourOfDay,
        Integer minute, Integer second, Integer milissecond) 

Method Source Code

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

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

public class Main {
    /**//from  ww  w . j  ava 2 s . c  om
     * Create a Date object based on default Calendar instance.
     * 
     * @param year
     * @param month
     * @param dayOfMonth
     * @param hourOfDay
     * @param minute
     * @param second
     * @param milissecond
     * @return
     */
    public static Date createDateObject(Integer year, Integer month, Integer dayOfMonth, Integer hourOfDay,
            Integer minute, Integer second, Integer milissecond) {
        Calendar c = Calendar.getInstance();

        c.set(Calendar.YEAR, year);
        c.set(Calendar.MONTH, month);
        c.set(Calendar.DAY_OF_MONTH, dayOfMonth);

        if (hourOfDay != null) {
            c.set(Calendar.HOUR_OF_DAY, hourOfDay);
        }
        if (minute != null) {
            c.set(Calendar.MINUTE, minute);
        }
        if (second != null) {
            c.set(Calendar.SECOND, second);
        }
        if (milissecond != null) {
            c.set(Calendar.MILLISECOND, milissecond);
        }

        return c.getTime();
    }
}

Related

  1. createDate(int year, int month, int day)
  2. createDate(int year, int month, int day)
  3. createDate(int year, int month, int day)
  4. createDate(int year, int month, int day, int hour, int minute, int second)
  5. createDate(int year, int month, int day, int hour, int minute, int second, int millisecond)
  6. createDates(int yy, int mm, int dd, int hh, int min, int ss)
  7. createDateString(long startDate, long endDate)
  8. createDateTime(Date date, Date time)
  9. createDateTime(int year, int month, int day, int hour, int minute, int second, String timezone)