Here you can find the source of createDate(int year, int month, int day, int hour, int minute, int second, int millisecond)
Parameter | Description |
---|---|
year | Four* digit year. When single decimals is used, set the current century from local date time. |
month | From January (1) to December (12) |
day | Day of the month. |
hour | 24 hour format. |
minute | a parameter |
second | a parameter |
millisecond | a parameter |
public static Date createDate(int year, int month, int day, int hour, int minute, int second, int millisecond)
//package com.java2s; /**/*from www . j av a 2 s . c o m*/ * The Accord Project, http://accordproject.org * Copyright (C) 2005-2013 Rafael Marins, http://rafaelmarins.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import java.util.Calendar; import java.util.Date; public class Main { /** * Create date from given values. Local timezone is used in returning date. * * @param year * Four* digit year. When single decimals is used, set the * current century from local date time. * @param month * From January (1) to December (12) * @param day * Day of the month. * @param hour * 24 hour format. * @param minute * @param second * @param millisecond * @return */ public static Date createDate(int year, int month, int day, int hour, int minute, int second, int millisecond) { Calendar cal = Calendar.getInstance(); // Must guarantee that the century is set. if ((year / 100) == 0) { // Use century from local date time Calendar int century = cal.get(Calendar.YEAR) / 100; year = (century * 100) + year; } // Convert conventional month range to Calendar month range. month--; cal.set(year, month, day, hour, minute, second); cal.set(Calendar.MILLISECOND, millisecond); return cal.getTime(); } }