Here you can find the source of createDate(int year, int month, int date)
java.util.Date
without time slice.
Parameter | Description |
---|---|
year | the given year |
month | the given month |
date | the given date |
java.util.Date
.
public static Date createDate(int year, int month, int date)
//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()); } }