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

DatecreateDate(int year, int month, int date)
Creates a java.util.Date without time slice.
return createDate(year, month, date, 0, 0, 0);
DatecreateDate(int year, int month, int date)
create Date
Calendar calendar = Calendar.getInstance();
calendar.set(year, month, date);
return calendar.getTime();
DatecreateDate(int year, int month, int day)
Returns a new date object based on the year, month and day provided.
Calendar calendar = Calendar.getInstance();
synchronized (calendar) {
    calendar.clear();
    calendar.set(year, month - 1, day);
    return calendar.getTime();
DatecreateDate(int year, int month, int day)
Creates the date.
Calendar cal = Calendar.getInstance();
cal.set(year, month, day, 0, 0, 0);
cal.set(Calendar.MILLISECOND, 0);
return cal.getTime();
longcreateDate(int year, int month, int day)
create Date
return createDate(year, month, day, 0, 0, 0);
DatecreateDate(int year, int month, int day)
Creates a Date object with the specfied value and the time fields set to zero.
final Calendar cal = Calendar.getInstance();
if (Integer.toString(year).length() > NR_OF_DIGITS_IN_YEAR) {
    throw new IllegalArgumentException("Year more than" + NR_OF_DIGITS_IN_YEAR + " digits long");
cal.set(Calendar.YEAR, year);
cal.set(Calendar.MONTH, month);
cal.set(Calendar.DAY_OF_MONTH, day);
cal.set(Calendar.HOUR_OF_DAY, 0);
...
DatecreateDate(int year, int month, int day)
create Date
return createDate(year, month, day, 0, 0, 0);
DatecreateDate(int year, int month, int day)
create Date
Calendar cal = Calendar.getInstance();
cal.set(Calendar.YEAR, year);
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);
...
DatecreateDate(int year, int month, int day, int hour, int minute, int second)
create Date
Calendar c = Calendar.getInstance();
c.set(year, month - 1, day, hour, minute, second);
c.set(Calendar.MILLISECOND, 0);
return c.getTime();
DatecreateDate(int year, int month, int day, int hour, int minute, int second, int millisecond)
Create date from given values.
Calendar cal = Calendar.getInstance();
if ((year / 100) == 0) {
    int century = cal.get(Calendar.YEAR) / 100;
    year = (century * 100) + year;
month--;
cal.set(year, month, day, hour, minute, second);
cal.set(Calendar.MILLISECOND, millisecond);
...