List of utility methods to do Date Set
Calendar | setDateToDayStart(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;
|
Date | setDateToStartOfDay(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); ... |
Date | setDayStart(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(); |
Date | setField(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.Date | setHour(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();
|
Date | setHourMinuteSecondToZeroPlus24Hours(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(); ... |
Date | setHours(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();
|
Date | setHours(Date date, int amount) set Hours return set(date, Calendar.HOUR_OF_DAY, amount);
|
Date | setMilliSecondsToDate(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; ... |
Date | setMinDate(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)); ... |