// Copyright 2003 by Basil Vandegriend.  All rights reserved.

package com.basilv.core;

import java.util.Calendar;
import java.util.Date;

/**
 * Utility methods for working with java.util.Date and related date classes
 */
public class DateUtilities
{

	/**
	 * Create a date from the specified year, month, day.
	 * 
	 * @param year
	 * @param month This is one-based, so 1 = January and 12 = December.
	 * @param dayOfMonth This ranges from 1 to 31
	 * @return the created date.
	 */
	public static Date createDate(int year, int month, int dayOfMonth) {
		Assert.greaterThanZero("year", year);
		Assert.isTrue(month >= 1 && month <= 12);
		Assert.isTrue(dayOfMonth >= 1 && dayOfMonth <= 31);

		Calendar calendar = Calendar.getInstance();
		calendar.set(year, month - 1, dayOfMonth, 0, 0);
		return calendar.getTime();
	}

}
