public class IlvMultipleTimeUnit extends IlvTimeUnit
IlvMultipleTimeUnit
class is used to create instances
that represents multiples of the following predefined time units:
IlvTimeUnit.MILLISECOND
,
IlvTimeUnit.SECOND
, IlvTimeUnit.MINUTE
, IlvTimeUnit.HOUR
,
IlvTimeUnit.DAY
, IlvTimeUnit.WEEK
,
IlvTimeUnit.MONTH
, IlvTimeUnit.YEAR
.
For example, the following code creates a time unit equal to 15 minutes:
IlvTimeUnit unit = new IlvMultipleTimeUnit(IlvTimeUnit.MINUTE, 15);
Constructor and Description |
---|
IlvMultipleTimeUnit(IlvTimeUnit baseUnit,
int mult)
Creates a multiple of the specified time unit.
|
IlvMultipleTimeUnit(IlvTimeUnit baseUnit,
int mult,
Date origin)
Creates a multiple of the specified time unit.
|
Modifier and Type | Method and Description |
---|---|
String |
getFormatString()
Returns a string pattern used by the
IlvTimeStepsDefinition class
to create a java.util.SimpleDateFormat object. |
String |
getFormatString(Locale locale)
Returns a string pattern used by the
IlvTimeStepsDefinition class
to create a java.util.SimpleDateFormat object. |
double |
getMillis()
Returns the number of milliseconds corresponding to this unit.
|
Calendar |
incrementTime(Calendar cal)
Increments the specified time according to this unit.
|
Calendar |
previousUnitTime(Calendar cal)
Truncates the given
Calendar downwards to the nearest
multiple of this unit. |
String |
toString()
Returns a string representation of this time unit.
|
format, format
public IlvMultipleTimeUnit(IlvTimeUnit baseUnit, int mult) throws IllegalArgumentException
baseUnit
- The base unit, which must be one of the following:
IlvTimeUnit.MINUTE
, IlvTimeUnit.HOUR
,
IlvTimeUnit.DAY
, IlvTimeUnit.WEEK
,
IlvTimeUnit.MONTH
and IlvTimeUnit.YEAR
.mult
- The multiplier.IllegalArgumentException
- If the multiplier is not strictly
positive.IllegalArgumentException
- If the base unit is not supported.public IlvMultipleTimeUnit(IlvTimeUnit baseUnit, int mult, Date origin) throws IllegalArgumentException
baseUnit
- The base unit, which must be one of the following:
IlvTimeUnit.MINUTE
, IlvTimeUnit.HOUR
,
IlvTimeUnit.DAY
, IlvTimeUnit.WEEK
,
IlvTimeUnit.MONTH
and IlvTimeUnit.YEAR
.mult
- The multiplier.origin
- Origin time point. Useful when this time unit does not
evenly divide the next bigger time unit, for example "7 hours"
or "2 weeks" or "5 months". Can also be null
.IllegalArgumentException
- If the multiplier is not strictly
positive.IllegalArgumentException
- If the base unit is not supported.public Calendar previousUnitTime(Calendar cal)
Calendar
downwards to the nearest
multiple of this unit.
The method modifies the cal
parameter and returns it.previousUnitTime
in class IlvTimeUnit
cal
- The considered time.public Calendar incrementTime(Calendar cal)
cal
parameter and returns it.incrementTime
in class IlvTimeUnit
cal
- The considered time.public double getMillis()
getMillis
in class IlvTimeUnit
public String getFormatString()
IlvTimeStepsDefinition
class
to create a java.util.SimpleDateFormat
object.
The default implementation returns the string pattern of the base unit.getFormatString
in class IlvTimeUnit
public String getFormatString(Locale locale)
IlvTimeStepsDefinition
class
to create a java.util.SimpleDateFormat
object.
The default implementation returns the string pattern of the base unit.getFormatString
in class IlvTimeUnit
locale
- The locale of the chart.© Copyright Rogue Wave Software, Inc. 1997, 2018. All Rights Reserved.