com.miginfocom.util.dates
Class MillisRounder

java.lang.Object
  extended by com.miginfocom.util.dates.MillisRounder
All Implemented Interfaces:
DateRangeRounder, java.io.Serializable

public class MillisRounder
extends java.lang.Object
implements DateRangeRounder

Rounds DateRangI's to specified intervals.

Mostly useable for simple rounding to seconds or minutes. Use BoundaryRounder for rounding to bigger boundaries than hours.

NOTE! This rounder rounds to a specific point i absolute time with no compensation for rounding over daylight savings and such.

See Also:
Serialized Form

Constructor Summary
MillisRounder(long millis, boolean roundStart, boolean roundEnd, boolean keepSameLength)
          Creates a MillisRounder.
 
Method Summary
 boolean getKeepSameLength()
           
 long getMillis()
           
 boolean getRoundEnd()
           
 boolean getRoundStart()
           
 MutableDateRange round(MutableDateRange dateRange)
          Rounds the start and/or end dates and possibly ajdusts the not rounded date/time so the length will be same.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

MillisRounder

public MillisRounder(long millis,
                     boolean roundStart,
                     boolean roundEnd,
                     boolean keepSameLength)
Creates a MillisRounder.

Parameters:
millis - The number of millis to round to. For instance 1000 would round to even seconds.
roundStart - If the start date/time should be rounded.
roundEnd - If the end date/time should be rounded.
keepSameLength - If not both of roundStart and roundEnd of a MutableDateRange are rounded and keepSameLength is true, the one of roundStart or roundEnd time that is not rounded will be set so that the spanned time in the range will remain the same.
If this is true, the result is actually a rounded move of the range rather than a resize.
keepSameLength can't be true if both roundStart and roundEnd is true.
Method Detail

round

public MutableDateRange round(MutableDateRange dateRange)
Description copied from interface: DateRangeRounder
Rounds the start and/or end dates and possibly ajdusts the not rounded date/time so the length will be same.

Specified by:
round in interface DateRangeRounder
Parameters:
dateRange - The MutableDateRange to round. Will be changed.
Returns:
dateRange for the possiblility to chain.

getMillis

public long getMillis()

getRoundStart

public boolean getRoundStart()

getRoundEnd

public boolean getRoundEnd()

getKeepSameLength

public boolean getKeepSameLength()


Copyright © 2009 MiG InfoCom AB. All Rights Reserved.