code: public static Calendar previousInterval(final long ts, final int interval, 
        final int unit) {
      return previousInterval(ts, interval, unit, null);
    }
docs: Returns a calendar set to the previous interval time based on the
  units and UTC the timezone. This allows for snapping to day, week,
  monthly, etc. boundaries.
  NOTE: It uses a calendar for snapping so isn't as efficient as a simple
  modulo calculation.
  NOTE: For intervals that don't nicely divide into their given unit (e.g.
  a 23s interval where 60 seconds is not divisible by 23) the base time may
  start at the top of the day (for ms and s) or from Unix epoch 0. In the
  latter case, setting up the base timestamp may be slow if the caller does
  something silly like "23m" where we iterate 23 minutes at a time from 0
  till we find the proper timestamp.
  TODO - There is likely a better way to do all of this
  @param ts The timestamp to find an interval for, in milliseconds as
  a Unix epoch.
  @param interval The interval as a measure of units.
  @param unit The unit. This must cast to a Calendar time unit.
  @return A calendar set to the timestamp aligned to the proper interval
  before the given ts
  @throws IllegalArgumentException if the timestamp is negative, if the
  interval is less than 1 or the unit is unrecognized.
  @since 2.3