List of utility methods to do Date to Day
Date | getDayEnd(Date obj) get Day End if (obj == null) { throw new NullPointerException(); Calendar ca = new GregorianCalendar(); ca.setTime(obj); ca.set(Calendar.HOUR_OF_DAY, 23); ca.set(Calendar.MINUTE, 59); ca.set(Calendar.SECOND, 59); ... |
Date | getDayEnd(final Date date, TimeZone timezone) Get a Date representing the end of the day for the specified date. Calendar calendar = Calendar.getInstance();
if (timezone != null) {
calendar.setTimeZone(timezone);
calendar.setTime(date);
calendar.set(Calendar.HOUR_OF_DAY, LAST_HOUR_IN_DAY);
calendar.set(Calendar.MINUTE, LAST_MINUTE_IN_HOUR);
calendar.set(Calendar.SECOND, LAST_SECOND_IN_MINUTE);
...
|
Integer | getDayFromDate(Date date) get Day From Date Integer result = null; if (date != null) { Calendar calendar = Calendar.getInstance(); calendar.setTime(date); result = calendar.get(Calendar.DATE); return result; |
String[] | getDayMonthYear(Date aDate, boolean isAddSpace) get day month year String[] dmys = new String[3]; if (aDate != null) { Calendar cal = Calendar.getInstance(); cal.setTime(aDate); int day = cal.get(Calendar.DAY_OF_MONTH); if (day < 10) { if (isAddSpace) { dmys[0] = "0 " + day; ... |
int | getDayNumber(Date startDate, Date endDate) get Day Number Calendar startCal = Calendar.getInstance(); startCal.setTime(startDate); Calendar endCal = Calendar.getInstance(); endCal.setTime(endDate); if (startCal.after(endCal)) { return 0; int num = 1; ... |
int | getDayOfDate(Date date) Description:Get Monday of the week the day specified by parameter belongs to Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
return calendar.get(Calendar.DAY_OF_WEEK) - Calendar.SUNDAY;
|
int | getDayOfThisYear(Date currentdate) get Day Of This Year Calendar cal = Calendar.getInstance(); if (currentdate != null) { cal.setTime(currentdate); } else { cal.setTime(new Date()); return cal.get(Calendar.DATE); |
int | getDayOfYear(Date date) get Day Of Year Calendar c = Calendar.getInstance(Locale.US);
c.setTime(date);
return c.get(Calendar.DAY_OF_YEAR);
|
int | getDays(Date t, Date baseDate) Get days difference between two dates Calendar cal = Calendar.getInstance(); cal.setTime(baseDate); long sl = cal.getTimeInMillis(); long el, delta; cal.setTime(t); el = cal.getTimeInMillis(); delta = el - sl; int value = (int) (delta / (24 * 60 * 60 * 1000)); ... |
Date | getDaysEarlierDate(int days) Purpose: getDaysEarlierDate Calendar cal = Calendar.getInstance();
cal.add(Calendar.DAY_OF_YEAR, -(days));
return cal.getTime();
|