Java Utililty Methods Date Set

List of utility methods to do Date Set

Description

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

Method

CalendarsetDateToDayStart(final Date date)
Return a Calendar with time set by the start of the given day.
Calendar startDate = Calendar.getInstance();
startDate.setTime(date);
startDate.set(Calendar.HOUR_OF_DAY, 0);
startDate.set(Calendar.MINUTE, 0);
startDate.set(Calendar.SECOND, 0);
startDate.set(Calendar.MILLISECOND, 0);
return startDate;
DatesetDateToStartOfDay(Date date)
set Date To Start Of Day
Date result = null;
if (date != null) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(date);
    int year = calendar.get(Calendar.YEAR);
    int month = calendar.get(Calendar.MONTH);
    int day = calendar.get(Calendar.DATE);
    calendar.set(year, month, day, 0, 0, 0);
...
DatesetDayStart(final Date date)
set Day Start
final Calendar c = Calendar.getInstance();
c.setLenient(false);
c.setTime(date);
c.set(Calendar.HOUR_OF_DAY, 0);
c.set(Calendar.MINUTE, 0);
c.set(Calendar.SECOND, 0);
return c.getTime();
DatesetField(Date date, int field, int value)
set Field
Date result = date;
if (date != null) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(date);
    calendar.set(field, value);
    result = calendar.getTime();
return result;
...
java.util.DatesetHour(java.util.Date date, Integer hour)
set Hour
java.util.Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.set(Calendar.HOUR, hour);
return cal.getTime();
DatesetHourMinuteSecondToZeroPlus24Hours(Date datetime)
Sets the hour minute second to zero plus24 hours.
final Calendar calendar = Calendar.getInstance();
calendar.setTime(datetime);
calendar.set(Calendar.HOUR, 23);
calendar.set(Calendar.MINUTE, 59);
calendar.set(Calendar.SECOND, 59);
calendar.set(Calendar.MILLISECOND, 0);
calendar.set(Calendar.AM_PM, 0);
return calendar.getTime();
...
DatesetHours(Date d, int hours)
Set hours to a date
Calendar cal = Calendar.getInstance();
cal.setTime(d);
cal.set(Calendar.HOUR_OF_DAY, hours);
return cal.getTime();
DatesetHours(Date date, int amount)
set Hours
return set(date, Calendar.HOUR_OF_DAY, amount);
DatesetMilliSecondsToDate(Date date, Integer milliSeconds)
set Milli Seconds To Date
Date result = null;
if (date != null) {
    Calendar calendar = Calendar.getInstance();
    calendar.setTime(date);
    calendar.set(Calendar.MILLISECOND, milliSeconds);
    result = calendar.getTime();
return result;
...
DatesetMinDate(Date d)
set Min Date
Calendar min = Calendar.getInstance();
min.setTime(d);
if (min.get(Calendar.AM_PM) == Calendar.AM) {
    min.set(Calendar.HOUR, 0);
} else {
    min.set(Calendar.HOUR, -12);
min.set(Calendar.MINUTE, min.getActualMinimum(Calendar.MINUTE));
...