1 package org.cacert.gigi.util;
3 import java.util.Calendar;
5 import java.util.GregorianCalendar;
6 import java.util.TimeZone;
8 public class CalendarUtil {
10 public static boolean isDateValid(int year, int month, int day) {
12 Calendar c = GregorianCalendar.getInstance();
13 c.set(year, month - 1, day);
14 return c.get(Calendar.YEAR) == year && c.get(Calendar.MONTH) == month - 1 && c.get(Calendar.DATE) == day;
18 public static DayDate getDateFromComponents(int year, int month, int day) {
19 Calendar cal = Calendar.getInstance();
20 cal.setTimeZone(TimeZone.getTimeZone("UTC"));
21 cal.setTimeInMillis(0);
22 cal.set(year, month - 1, day, 0, 0, 0);
23 Date dob = cal.getTime();
24 return new DayDate(dob.getTime());