Java tutorial
//package com.java2s; import java.util.Calendar; public class Main { public static java.util.Date getDate(int y, int m, int d, boolean inclusive) { java.util.Date dt = null; Calendar c = Calendar.getInstance(); c.clear(); if (c.getActualMinimum(1) <= y && y <= c.getActualMaximum(1)) { c.set(1, y); if (c.getActualMinimum(2) <= m && m <= c.getActualMaximum(2)) { c.set(2, m); if (c.getActualMinimum(5) <= d && d <= c.getActualMaximum(5)) c.set(5, d); } if (inclusive) { c.add(5, 1); c.add(14, -1); } dt = c.getTime(); } return dt; } }