Skip navigation links

Oracle® Information Rights Management Server Java API Reference
11g Release 1 (11.1.1)

E12907-03


oracle.irm.engine.core.time
Interface TimePeriod


public interface TimePeriod

A definition of a length of time. A time period stores a period of time as a numeric value and the time units - years, days, hours, minutes or seconds. A time period can have a positive or negative value - indicating the direction of the time period. A negative time period amount would mean that the time period is in the past, a positive time period would mean the time period is in the future.

Creation

Instances of Time Period objects can be created using the following factory style method(s).

TimePeriod object = createTimePeriod(
    amount,
    units);

Collections

Collections for TimePeriod objects can be created using the following factory method. This method creates the most appropriate collection implementation class for storing TimePeriod elements.

 Collection<TimePeriod> object = createTimePeriods();

XML Serialization

Time Period instances can be serialized as an XML document. This XML document can also be used to recreate a Time Period object. The following XML document shows an example Time Period in XML form.

<?xml version="1.0" encoding="UTF-8"?>
<core:TimePeriod xmlns:core="http://xmlns.oracle.com/irm/core">
    <amount>30</amount>
    <units>MINUTES</units>
</core:TimePeriod>


Nested Class Summary
static class TimePeriod.Units
          Time units.

 

Method Summary
 Date addToTime(Date dateTime)
          Add this time period to a date and time.
 int getAmount()
          The time period amount.
 TimePeriod.Units getUnits()
          Time units.
 Date startOfPeriod(Date dateTime)
          Work out the start of the specified period.
 long toSeconds()
          Convert this time period to seconds.

 

Method Detail

getAmount

int getAmount()
The time period amount. e.g. two minutes, two hours.
Returns:
the value of the property.

getUnits

TimePeriod.Units getUnits()
Time units. e.g. two minutes, two hours.
Returns:
the value of the property. This method will never return null.

addToTime

Date addToTime(Date dateTime)
Add this time period to a date and time. If the time period is negative the resultant date and time will be in the past.
Parameters:
dateTime - the date and time.
Returns:
the date and time with the time period added. This method will never return null.

startOfPeriod

Date startOfPeriod(Date dateTime)
Work out the start of the specified period. For example, given a date, find out when the start of the month is.
Parameters:
dateTime - the date and time.
Returns:
the date and time at the start if the appropriate period. This method will never return null.

toSeconds

long toSeconds()
Convert this time period to seconds. This method uses thirty one days in a month when calculating the number of seconds in a month.
Returns:
the time period in seconds.

Skip navigation links

Oracle® Information Rights Management Server Java API Reference
11g Release 1 (11.1.1)

E12907-03


Copyright © 2011, Oracle. All rights reserved.