List of utility methods to do Date to Day
Date | getDay(Date date) get Day long time = date.getTime(); return new Date(time - ((time + timezoneOffset) % 86400000L)); |
Date | getDay(Date date, int day) get Day long currDateMills = date.getTime(); long extraMills = day * 3600 * 1000 * 24; Calendar result = Calendar.getInstance(); result.setTimeInMillis(currDateMills + extraMills); return result.getTime(); |
int | getDay(Date dateParam) get Day if (dateParam == null) { throw new IllegalArgumentException("The dateParam must not be null"); Calendar cal = Calendar.getInstance(); cal.setTimeInMillis(dateParam.getTime()); return cal.get(Calendar.DAY_OF_WEEK); |
int | getDay(java.util.Date date) get Day java.util.Calendar c = java.util.Calendar.getInstance();
c.setTime(date);
return c.get(java.util.Calendar.DAY_OF_MONTH);
|
int | getDay(String strDate) get Day Calendar cal = parseDateTime(strDate);
return cal.get(Calendar.DATE);
|
Integer | getDayBetween(Date startDate, Date endDate) get Day Between Calendar start = Calendar.getInstance(); start.setTime(startDate); start.set(Calendar.HOUR_OF_DAY, 0); start.set(Calendar.MINUTE, 0); start.set(Calendar.SECOND, 0); start.set(Calendar.MILLISECOND, 0); Calendar end = Calendar.getInstance(); end.setTime(endDate); ... |
int | getDayCount(java.util.Date _startDate, java.util.Date _endDate) get Day Count Calendar calendar = Calendar.getInstance(); calendar.setTime(_startDate); int startDay = calendar.get(Calendar.DAY_OF_YEAR); int startYear = calendar.get(Calendar.YEAR); calendar.clear(); calendar.setTime(_endDate); int endDay = calendar.get(Calendar.DAY_OF_YEAR); int endYear = calendar.get(Calendar.YEAR); ... |
Date | getDayEnd(Date date) get Day End Calendar calendar = Calendar.getInstance(); calendar.setTime(date); calendar.set(Calendar.HOUR_OF_DAY, 0); calendar.set(Calendar.MINUTE, 0); calendar.set(Calendar.SECOND, 0); calendar.set(Calendar.MILLISECOND, 0); calendar.add(Calendar.DAY_OF_MONTH, 1); calendar.add(Calendar.MILLISECOND, -1); ... |
Date | getDayEnd(Date date) Calculates end of the day Calendar end = new GregorianCalendar(); end.setTime(date); end.set(Calendar.HOUR_OF_DAY, 23); end.set(Calendar.MINUTE, 59); end.set(Calendar.SECOND, 59); return end.getTime(); |
Calendar | getDayEnd(Date date) Gets a date which is at the end of a day. Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.set(Calendar.HOUR_OF_DAY, 23);
cal.set(Calendar.MINUTE, 59);
cal.set(Calendar.SECOND, 59);
cal.set(Calendar.MILLISECOND, 999);
return cal;
|