public static DateTime floorToMinutePeriod(DateTime value, int periodInMinutes) {
        if (value == null) {
            return null;
        }
        if (periodInMinutes <= 0 || periodInMinutes > 59) {
            throw new IllegalArgumentException("period in minutes must be > 0 and <= 59");
        }
        int min = value.getMinuteOfHour();
        min = (min / periodInMinutes) * periodInMinutes;
        return new DateTime(value.getYear(), value.getMonthOfYear(), value.getDayOfMonth(), value.getHourOfDay(), min, 0, 0, value.getZone());
    }
public static DateTime floorToMinutePeriod ( DateTime value , int periodInMinutes ) { if ( value == null ) { return null ; } if ( periodInMinutes <= 0 || periodInMinutes > 59 ) { throw new IllegalArgumentException ( "period in minutes must be > 0 and <= 59" ) ; } int min = value . getMinuteOfHour ( ) ; min = ( min / periodInMinutes ) * periodInMinutes ; return new DateTime ( value . getYear ( ) , value . getMonthOfYear ( ) , value . getDayOfMonth ( ) , value . getHourOfDay ( ) , min , 0 , 0 , value . getZone ( ) ) ; }
Null-safe method that returns a new instance of a DateTime object rounded
downwards to the nearest specified period in minutes. For example, if
a period of 5 minutes is requested, a time of "2009-06-24 13:24:51.476 -8:00"
would return a datetime of "2009-06-24 13:20:00.000 -8:00". The time zone of the
returned DateTime instance will be the same as the argument. Similar to a
floor() function on a float.<br>
NOTE: While any period in minutes between 1 and 59 can be passed into this
method, its only useful if the value can be evenly divided into 60 to make
it as useful as possible.<br>
Examples:
<ul>
<li>null -> null
<li>5: "2009-06-24 13:39:51.476 -8:00" -> "2009-06-24 13:35:00.000 -8:00"
<li>10: "2009-06-24 13:39:51.476 -8:00" -> "2009-06-24 13:30:00.000 -8:00"
<li>15: "2009-06-24 13:39:51.476 -8:00" -> "2009-06-24 13:30:00.000 -8:00"
<li>20: "2009-06-24 13:39:51.476 UTC" -> "2009-06-24 13:20:00.000 UTC"
</ul>
@param value The DateTime value to round downward
@return Null if the argument is null or a new instance of the DateTime
value rounded downwards to the nearest period in minutes.