/** * <p>Truncate this date, leaving the field specified as the most * significant field.</p> * * <p>For example, if you had the datetime of 28 Mar 2002 * 13:45:01.231, if you passed with HOUR, it would return 28 Mar * 2002 13:00:00.000. If this was passed with MONTH, it would * return 1 Mar 2002 0:00:00.000.</p> * * @param date the date to work with * @param field the field from <code>Calendar</code> * or <code>SEMI_MONTH</code> * @return the rounded date (a different object) * @throws IllegalArgumentException if the date is <code>null</code> * @throws ArithmeticException if the year is over 280 million */ public static Calendar truncate(Calendar date, int field) { if (date == null) { throw new IllegalArgumentException("The date must not be null"); } Calendar truncated = (Calendar) date.clone(); modify(truncated, field, MODIFY_TRUNCATE); return truncated; }
/** * <p>Ceil this date, leaving the field specified as the most * significant field.</p> * * <p>For example, if you had the datetime of 28 Mar 2002 * 13:45:01.231, if you passed with HOUR, it would return 28 Mar * 2002 13:00:00.000. If this was passed with MONTH, it would * return 1 Mar 2002 0:00:00.000.</p> * * @param date the date to work with * @param field the field from <code>Calendar</code> * or <code>SEMI_MONTH</code> * @return the rounded date (a different object) * @throws IllegalArgumentException if the date is <code>null</code> * @throws ArithmeticException if the year is over 280 million * @since 2.5 */ public static Calendar ceiling(Calendar date, int field) { if (date == null) { throw new IllegalArgumentException("The date must not be null"); } Calendar ceiled = (Calendar) date.clone(); modify(ceiled, field, MODIFY_CEILING); return ceiled; }
modify(rounded, field, MODIFY_ROUND); return rounded;
/** * <p>Truncate this date, leaving the field specified as the most * significant field.</p> * * <p>For example, if you had the datetime of 28 Mar 2002 * 13:45:01.231, if you passed with HOUR, it would return 28 Mar * 2002 13:00:00.000. If this was passed with MONTH, it would * return 1 Mar 2002 0:00:00.000.</p> * * @param date the date to work with * @param field the field from <code>Calendar</code> * or <code>SEMI_MONTH</code> * @return the rounded date * @throws IllegalArgumentException if the date is <code>null</code> * @throws ArithmeticException if the year is over 280 million */ public static Date truncate(Date date, int field) { if (date == null) { throw new IllegalArgumentException("The date must not be null"); } Calendar gval = Calendar.getInstance(); gval.setTime(date); modify(gval, field, MODIFY_TRUNCATE); return gval.getTime(); }
/** * <p>Ceil this date, leaving the field specified as the most * significant field.</p> * * <p>For example, if you had the datetime of 28 Mar 2002 * 13:45:01.231, if you passed with HOUR, it would return 28 Mar * 2002 13:00:00.000. If this was passed with MONTH, it would * return 1 Mar 2002 0:00:00.000.</p> * * @param date the date to work with * @param field the field from <code>Calendar</code> * or <code>SEMI_MONTH</code> * @return the rounded date * @throws IllegalArgumentException if the date is <code>null</code> * @throws ArithmeticException if the year is over 280 million * @since 2.5 */ public static Date ceiling(Date date, int field) { if (date == null) { throw new IllegalArgumentException("The date must not be null"); } Calendar gval = Calendar.getInstance(); gval.setTime(date); modify(gval, field, MODIFY_CEILING); return gval.getTime(); }
modify(gval, field, MODIFY_ROUND); return gval.getTime();
/** * <p>Truncate this date, leaving the field specified as the most * significant field.</p> * * <p>For example, if you had the datetime of 28 Mar 2002 * 13:45:01.231, if you passed with HOUR, it would return 28 Mar * 2002 13:00:00.000. If this was passed with MONTH, it would * return 1 Mar 2002 0:00:00.000.</p> * * @param date the date to work with * @param field the field from <code>Calendar</code> * or <code>SEMI_MONTH</code> * @return the rounded date (a different object) * @throws IllegalArgumentException if the date is <code>null</code> * @throws ArithmeticException if the year is over 280 million */ public static Calendar truncate(Calendar date, int field) { if (date == null) { throw new IllegalArgumentException("The date must not be null"); } Calendar truncated = (Calendar) date.clone(); modify(truncated, field, MODIFY_TRUNCATE); return truncated; }
/** * <p>Truncate this date, leaving the field specified as the most * significant field.</p> * * <p>For example, if you had the datetime of 28 Mar 2002 * 13:45:01.231, if you passed with HOUR, it would return 28 Mar * 2002 13:00:00.000. If this was passed with MONTH, it would * return 1 Mar 2002 0:00:00.000.</p> * * @param date the date to work with * @param field the field from <code>Calendar</code> * or <code>SEMI_MONTH</code> * @return the rounded date (a different object) * @throws IllegalArgumentException if the date is <code>null</code> * @throws ArithmeticException if the year is over 280 million */ public static Calendar truncate(Calendar date, int field) { if (date == null) { throw new IllegalArgumentException("The date must not be null"); } Calendar truncated = (Calendar) date.clone(); modify(truncated, field, MODIFY_TRUNCATE); return truncated; }
/** * <p>Truncate this date, leaving the field specified as the most * significant field.</p> * * <p>For example, if you had the datetime of 28 Mar 2002 * 13:45:01.231, if you passed with HOUR, it would return 28 Mar * 2002 13:00:00.000. If this was passed with MONTH, it would * return 1 Mar 2002 0:00:00.000.</p> * * @param date the date to work with * @param field the field from <code>Calendar</code> * or <code>SEMI_MONTH</code> * @return the rounded date (a different object) * @throws IllegalArgumentException if the date is <code>null</code> * @throws ArithmeticException if the year is over 280 million */ public static Calendar truncate(Calendar date, int field) { if (date == null) { throw new IllegalArgumentException("The date must not be null"); } Calendar truncated = (Calendar) date.clone(); modify(truncated, field, MODIFY_TRUNCATE); return truncated; }
/** * <p>Ceil this date, leaving the field specified as the most * significant field.</p> * * <p>For example, if you had the datetime of 28 Mar 2002 * 13:45:01.231, if you passed with HOUR, it would return 28 Mar * 2002 13:00:00.000. If this was passed with MONTH, it would * return 1 Mar 2002 0:00:00.000.</p> * * @param date the date to work with * @param field the field from <code>Calendar</code> * or <code>SEMI_MONTH</code> * @return the rounded date (a different object) * @throws IllegalArgumentException if the date is <code>null</code> * @throws ArithmeticException if the year is over 280 million * @since 2.5 */ public static Calendar ceiling(Calendar date, int field) { if (date == null) { throw new IllegalArgumentException("The date must not be null"); } Calendar ceiled = (Calendar) date.clone(); modify(ceiled, field, MODIFY_CEILING); return ceiled; }
/** * <p>Truncate this date, leaving the field specified as the most * significant field.</p> * * <p>For example, if you had the datetime of 28 Mar 2002 * 13:45:01.231, if you passed with HOUR, it would return 28 Mar * 2002 13:00:00.000. If this was passed with MONTH, it would * return 1 Mar 2002 0:00:00.000.</p> * * @param date the date to work with * @param field the field from <code>Calendar</code> * or <code>SEMI_MONTH</code> * @return the rounded date (a different object) * @throws IllegalArgumentException if the date is <code>null</code> * @throws ArithmeticException if the year is over 280 million */ public static Calendar truncate(Calendar date, int field) { if (date == null) { throw new IllegalArgumentException("The date must not be null"); } Calendar truncated = (Calendar) date.clone(); modify(truncated, field, MODIFY_TRUNCATE); return truncated; }
/** * <p>Ceil this date, leaving the field specified as the most * significant field.</p> * * <p>For example, if you had the datetime of 28 Mar 2002 * 13:45:01.231, if you passed with HOUR, it would return 28 Mar * 2002 13:00:00.000. If this was passed with MONTH, it would * return 1 Mar 2002 0:00:00.000.</p> * * @param date the date to work with * @param field the field from <code>Calendar</code> * or <code>SEMI_MONTH</code> * @return the rounded date (a different object) * @throws IllegalArgumentException if the date is <code>null</code> * @throws ArithmeticException if the year is over 280 million * @since 2.5 */ public static Calendar ceiling(Calendar date, int field) { if (date == null) { throw new IllegalArgumentException("The date must not be null"); } Calendar ceiled = (Calendar) date.clone(); modify(ceiled, field, MODIFY_CEILING); return ceiled; }
/** * <p>Ceil this date, leaving the field specified as the most * significant field.</p> * * <p>For example, if you had the datetime of 28 Mar 2002 * 13:45:01.231, if you passed with HOUR, it would return 28 Mar * 2002 13:00:00.000. If this was passed with MONTH, it would * return 1 Mar 2002 0:00:00.000.</p> * * @param date the date to work with * @param field the field from <code>Calendar</code> * or <code>SEMI_MONTH</code> * @return the rounded date (a different object) * @throws IllegalArgumentException if the date is <code>null</code> * @throws ArithmeticException if the year is over 280 million * @since 2.5 */ public static Calendar ceiling(Calendar date, int field) { if (date == null) { throw new IllegalArgumentException("The date must not be null"); } Calendar ceiled = (Calendar) date.clone(); modify(ceiled, field, MODIFY_CEILING); return ceiled; }
/** * <p>Ceil this date, leaving the field specified as the most * significant field.</p> * * <p>For example, if you had the datetime of 28 Mar 2002 * 13:45:01.231, if you passed with HOUR, it would return 28 Mar * 2002 13:00:00.000. If this was passed with MONTH, it would * return 1 Mar 2002 0:00:00.000.</p> * * @param date the date to work with * @param field the field from <code>Calendar</code> * or <code>SEMI_MONTH</code> * @return the rounded date (a different object) * @throws IllegalArgumentException if the date is <code>null</code> * @throws ArithmeticException if the year is over 280 million * @since 2.5 */ public static Calendar ceiling(Calendar date, int field) { if (date == null) { throw new IllegalArgumentException("The date must not be null"); } Calendar ceiled = (Calendar) date.clone(); modify(ceiled, field, MODIFY_CEILING); return ceiled; }
/** * <p>Ceil this date, leaving the field specified as the most * significant field.</p> * * <p>For example, if you had the datetime of 28 Mar 2002 * 13:45:01.231, if you passed with HOUR, it would return 28 Mar * 2002 13:00:00.000. If this was passed with MONTH, it would * return 1 Mar 2002 0:00:00.000.</p> * * @param date the date to work with * @param field the field from <code>Calendar</code> * or <code>SEMI_MONTH</code> * @return the rounded date (a different object) * @throws IllegalArgumentException if the date is <code>null</code> * @throws ArithmeticException if the year is over 280 million * @since 2.5 */ public static Calendar ceiling(Calendar date, int field) { if (date == null) { throw new IllegalArgumentException("The date must not be null"); } Calendar ceiled = (Calendar) date.clone(); modify(ceiled, field, MODIFY_CEILING); return ceiled; }
/** * <p>Truncate this date, leaving the field specified as the most * significant field.</p> * * <p>For example, if you had the datetime of 28 Mar 2002 * 13:45:01.231, if you passed with HOUR, it would return 28 Mar * 2002 13:00:00.000. If this was passed with MONTH, it would * return 1 Mar 2002 0:00:00.000.</p> * * @param date the date to work with * @param field the field from <code>Calendar</code> * or <code>SEMI_MONTH</code> * @return the rounded date * @throws IllegalArgumentException if the date is <code>null</code> * @throws ArithmeticException if the year is over 280 million */ public static Date truncate(Date date, int field) { if (date == null) { throw new IllegalArgumentException("The date must not be null"); } Calendar gval = Calendar.getInstance(); gval.setTime(date); modify(gval, field, MODIFY_TRUNCATE); return gval.getTime(); }
/** * <p>Truncate this date, leaving the field specified as the most * significant field.</p> * * <p>For example, if you had the datetime of 28 Mar 2002 * 13:45:01.231, if you passed with HOUR, it would return 28 Mar * 2002 13:00:00.000. If this was passed with MONTH, it would * return 1 Mar 2002 0:00:00.000.</p> * * @param date the date to work with * @param field the field from <code>Calendar</code> * or <code>SEMI_MONTH</code> * @return the rounded date * @throws IllegalArgumentException if the date is <code>null</code> * @throws ArithmeticException if the year is over 280 million */ public static Date truncate(Date date, int field) { if (date == null) { throw new IllegalArgumentException("The date must not be null"); } Calendar gval = Calendar.getInstance(); gval.setTime(date); modify(gval, field, MODIFY_TRUNCATE); return gval.getTime(); }
/** * <p>Ceil this date, leaving the field specified as the most * significant field.</p> * * <p>For example, if you had the datetime of 28 Mar 2002 * 13:45:01.231, if you passed with HOUR, it would return 28 Mar * 2002 13:00:00.000. If this was passed with MONTH, it would * return 1 Mar 2002 0:00:00.000.</p> * * @param date the date to work with * @param field the field from <code>Calendar</code> * or <code>SEMI_MONTH</code> * @return the rounded date * @throws IllegalArgumentException if the date is <code>null</code> * @throws ArithmeticException if the year is over 280 million * @since 2.5 */ public static Date ceiling(Date date, int field) { if (date == null) { throw new IllegalArgumentException("The date must not be null"); } Calendar gval = Calendar.getInstance(); gval.setTime(date); modify(gval, field, MODIFY_CEILING); return gval.getTime(); }
/** * <p>Ceil this date, leaving the field specified as the most * significant field.</p> * * <p>For example, if you had the datetime of 28 Mar 2002 * 13:45:01.231, if you passed with HOUR, it would return 28 Mar * 2002 13:00:00.000. If this was passed with MONTH, it would * return 1 Mar 2002 0:00:00.000.</p> * * @param date the date to work with * @param field the field from <code>Calendar</code> * or <code>SEMI_MONTH</code> * @return the rounded date * @throws IllegalArgumentException if the date is <code>null</code> * @throws ArithmeticException if the year is over 280 million * @since 2.5 */ public static Date ceiling(Date date, int field) { if (date == null) { throw new IllegalArgumentException("The date must not be null"); } Calendar gval = Calendar.getInstance(); gval.setTime(date); modify(gval, field, MODIFY_CEILING); return gval.getTime(); }
/** * <p>Ceil this date, leaving the field specified as the most * significant field.</p> * * <p>For example, if you had the datetime of 28 Mar 2002 * 13:45:01.231, if you passed with HOUR, it would return 28 Mar * 2002 13:00:00.000. If this was passed with MONTH, it would * return 1 Mar 2002 0:00:00.000.</p> * * @param date the date to work with * @param field the field from <code>Calendar</code> * or <code>SEMI_MONTH</code> * @return the rounded date * @throws IllegalArgumentException if the date is <code>null</code> * @throws ArithmeticException if the year is over 280 million * @since 2.5 */ public static Date ceiling(Date date, int field) { if (date == null) { throw new IllegalArgumentException("The date must not be null"); } Calendar gval = Calendar.getInstance(); gval.setTime(date); modify(gval, field, MODIFY_CEILING); return gval.getTime(); }