Author: fdesbois Date: 2010-02-26 18:11:54 +0100 (Fri, 26 Feb 2010) New Revision: 1778 Modified: trunk/src/main/java/org/nuiton/util/DateUtils.java Log: Remove duplicated methods + refactor strange method name Modified: trunk/src/main/java/org/nuiton/util/DateUtils.java =================================================================== --- trunk/src/main/java/org/nuiton/util/DateUtils.java 2010-02-26 16:28:09 UTC (rev 1777) +++ trunk/src/main/java/org/nuiton/util/DateUtils.java 2010-02-26 17:11:54 UTC (rev 1778) @@ -274,61 +274,17 @@ /** * Get the date before today (so yesterday no ?) + * * @param date concerned * @return Date before today */ - public static Date getLastDayDate(Date date) { - Calendar cal = Calendar.getInstance(); - cal.setTime(date); + public static Date getYesterday(Date date) { + Calendar cal = getDefaultCalendar(date); cal.roll(Calendar.DAY_OF_MONTH, false); - return cal.getTime(); } /** - * Get the first day of the current month - * @param date concerned - * @return Date of first day of current month - */ - public static Date getBeginMonthDate(Date date) { - Calendar cal = Calendar.getInstance(); - cal.setTime(date); - cal.set(Calendar.DAY_OF_MONTH, 1); - - return cal.getTime(); - } - - /** - * Get the begin date of the day - * @param date concerned - * @return Date of the begin of the day - */ - public static Date getBeginOfDayDate(Date date) { - Calendar calBegin = Calendar.getInstance(); - calBegin.setTime(date); - calBegin.set(Calendar.HOUR, 0); - calBegin.set(Calendar.MINUTE, 0); - calBegin.set(Calendar.SECOND, 0); - - return calBegin.getTime(); - } - - /** - * Get the end date of the day - * @param date concerned - * @return Date of the end of the day - */ - public static Date getEndOfDayDate(Date date) { - Calendar calEnd = Calendar.getInstance(); - calEnd.setTime(date); - calEnd.set(Calendar.HOUR, 23); - calEnd.set(Calendar.MINUTE, 59); - calEnd.set(Calendar.SECOND, 59); - - return calEnd.getTime(); - } - - /** * Get the calendar corresponding to the {@code date}. The default calendar * will be returned (default time zone and locale). *
participants (1)
-
fdesbois@users.nuiton.org