Java Utililty Methods Date Create

List of utility methods to do Date Create

Description

The list of methods to do Date Create are organized into topic(s).

Method

intdate(Date d)
date
Calendar cal = Calendar.getInstance();
cal.setTime(d);
return cal.get(Calendar.DATE);
Datedate(final int year, final int month, final int dayOfMonth)
An easy and non-deprecated non-lenient way of creating Date objects.
final Calendar cal = Calendar.getInstance();
cal.setLenient(false);
cal.set(year, month - 1, dayOfMonth, 0, 0, 0);
cal.set(Calendar.MILLISECOND, 0);
return cal.getTime();
Calendardate(int day, int month, int year)
date
return new GregorianCalendar(year, month - 1, day);
Datedate(int y, int m, int d)
date
Calendar c = Calendar.getInstance();
c.set(Calendar.YEAR, y + 1900);
c.set(Calendar.MONTH, m);
c.set(Calendar.DAY_OF_MONTH, d);
return c.getTime();
Datedate(int year, int month, int date)
date
Calendar working = GregorianCalendar.getInstance();
working.set(year, month, date, 0, 0, 1);
return working.getTime();
Datedate(int year, int month, int day)
date
Calendar cal = Calendar.getInstance();
cal.setTimeZone(TimeZone.getTimeZone("GMT"));
cal.set(year - 1900, month - 1, day);
return cal.getTime();
Datedate(int year, int month, int day)
date
Calendar calendar = Calendar.getInstance();
calendar.set(year, month - 1, day, 0, 0, 0);
calendar.set(Calendar.MILLISECOND, 0);
return calendar.getTime();
Datedate(int year, int month, int day)
Convenience method to create a new date
return date(year, month, day, 0, 0, 0);
Calendardate(int year, int month, int day)
date
Calendar calendar = Calendar.getInstance();
calendar.set(Calendar.YEAR, year);
calendar.set(Calendar.MONTH, month);
calendar.set(Calendar.DAY_OF_MONTH, day);
calendar.set(Calendar.HOUR_OF_DAY, 0);
calendar.set(Calendar.MINUTE, 0);
calendar.set(Calendar.SECOND, 0);
calendar.set(Calendar.MILLISECOND, 0);
...
Datedate(int year, int month, int day, int hour, int minute)
date
Calendar c = Calendar.getInstance();
c.set(year, month - 1, day, hour, minute, 0);
c.set(Calendar.MILLISECOND, 0);
return c.getTime();