Here you can find the source of getDate(int year, int month, int day)
Parameter | Description |
---|---|
year | a year |
month | a month (between 1 eand 12) |
day | a day in <code>month</code> (between 1 and 31) |
public static Date getDate(int year, int month, int day)
//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(); } }