Here you can find the source of createDate(int year, int month, int day)
public static Date createDate(int year, int month, int day)
//package com.java2s; /**// www . j av a 2 s . c om * Copyright (c) 2009 - 2012 Red Hat, Inc. * * This software is licensed to you under the GNU General Public License, * version 2 (GPLv2). There is NO WARRANTY for this software, express or * implied, including the implied warranties of MERCHANTABILITY or FITNESS * FOR A PARTICULAR PURPOSE. You should have received a copy of GPLv2 * along with this software; if not, see * http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt. * * Red Hat trademarks are not licensed under GPLv2. No permission is * granted to use or replicate Red Hat trademarks that are incorporated * in this software or its documentation. */ import java.util.Calendar; import java.util.Date; public class Main { public static Date createDate(int year, int month, int day) { Calendar cal = Calendar.getInstance(); cal.set(Calendar.YEAR, year); // Watch out! Java expects month as 0-11 cal.set(Calendar.MONTH, month - 1); cal.set(Calendar.DATE, day); cal.set(Calendar.HOUR_OF_DAY, 0); cal.set(Calendar.MINUTE, 0); cal.set(Calendar.SECOND, 0); cal.set(Calendar.MILLISECOND, 0); Date jsqlD = new Date(cal.getTime().getTime()); return jsqlD; } }