Java Date Create createDate(int year, int month, int date)

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

Description

Creates a java.util.Date without time slice.

License

Open Source License

Parameter

Parameter Description
year the given year
month the given month
date the given date

Return

the created java.util.Date.

Declaration

public static Date createDate(int year, int month, int date) 

Method Source Code

//package com.java2s;
/*/*from  ww w.  j  a va2s.  c  o m*/
 * Utility class for a easy way to handle Date
 * Copyright (C) 2012 Martin Absmeier, IT Consulting Services
 *
 *  This program is free software: you can redistribute it and/or modify
 *  it under the terms of the GNU General Public License as published by
 *  the Free Software Foundation, either version 3 of the License, or
 *  (at your option) any later version.
 *
 *  This program is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU General Public License for more details.
 *
 *  You should have received a copy of the GNU General Public License
 *  along with this program. If not, see <http://www.gnu.org/licenses/>.
 */

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

public class Main {
    /**
     * Creates a <code>java.util.Date</code> <b>without</b> time slice.
     * 
     * @param year
     *            the given year
     * @param month
     *            the given month
     * @param date
     *            the given date
     * @return the created <code>java.util.Date</code>.
     */
    public static Date createDate(int year, int month, int date) {
        return createDate(year, month, date, 0, 0, 0);
    }

    /**
     * Creates a <code>java.util.Date</code> <b>with</b> time slice.
     * 
     * @param year
     *            the given year
     * @param month
     *            the given month
     * @param date
     *            the given date
     * @param hourOfDay
     *            the given hour of day
     * @param minute
     *            the given minute
     * @param second
     *            the given second
     * @return the created <code>java.util.Date</code>.
     */
    public static Date createDate(int year, int month, int date, int hourOfDay, int minute, int second) {
        Calendar cal = Calendar.getInstance();
        cal.set(year, (month - 1), date, hourOfDay, minute, second);

        return new Date(cal.getTimeInMillis());
    }
}

Related

  1. createDate(final int year, final int month, final int day, final int hour, final int minute, final int second, final int millisecond)
  2. createDate(final int yyyy, final int month, final int day)
  3. createDate(int month, int day)
  4. createDate(int year, int month, int date)
  5. createDate(int year, int month, int date)
  6. createDate(int year, int month, int date)
  7. createDate(int year, int month, int day)
  8. createDate(int year, int month, int day)
  9. createDate(int year, int month, int day)