Esri Geoportal Server
1.0

com.esri.gpt.framework.util
Class TimePeriod

java.lang.Object
  extended by com.esri.gpt.framework.util.TimePeriod
All Implemented Interfaces:
Serializable

public final class TimePeriod
extends Object
implements Serializable

Time period. Represents time period in one of various forms indicating a number of milliseconds to elapse until defined moment in time.
Generic way of creating instance of the class is to use static method parseValue(java.lang.String). That method understands several different ways of expressing a time period.

The simplest way of creating time period is by providing number of milliseconds. Use a simple integer number like this:
  TimePeriod.parse("1000");
to create a a constant, one second period.

Another way to create period is to use one of the values from TimePeriod.Unit. Combining integer value with the unit name simplifies expressing longer periods, for example:
  TimePeriod.parse("2[DAY]");
gives just two days constant period.

There is also a way to express relative periods. Giving:
  TimePeriod.parse("08:00");
gives a period from now on to the closest eight o'clock am every day.

It is also possible to use one of the values of TimePeriod.DayOfWeek, like this:
  TimePeriod.parse("monday");
which means period from now on to the begining of the closes Monday, or even more specific way:
  TimePeriod.parse("monday 08:00");
to have period from now on to the eight o'clock am of the Monday.

It is also possible to parse array of time periods:
  TimePeriod.parse("08:00,sunday 10:00");
which gives period of eight o'clock every day and ten o'clock every sunday, whatever comes first.

See Also:
Serialized Form

Nested Class Summary
static class TimePeriod.DayOfWeek
          Day of the week.
static class TimePeriod.Unit
          Time unit.
 
Constructor Summary
TimePeriod()
          Creates instance of time period.
TimePeriod(long value)
          Creates instance of time period.
TimePeriod(long value, TimePeriod.Unit unit)
          Creates instance of time period.
 
Method Summary
 long getValue()
          Gets value.
 long getValue(Date since)
          Gets value.
static TimePeriod parseValue(String value)
          Parses value into time period.
 void setValue(long value)
          Sets value.
 void setValue(long value, TimePeriod.Unit unit)
          Sets value.
 String toLocalizedString(MessageBroker mb)
          Converts into localized string.
 String toString()
          Creates string representation of the object.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TimePeriod

public TimePeriod()
Creates instance of time period.


TimePeriod

public TimePeriod(long value)
Creates instance of time period.

Parameters:
value - value in milliseconds

TimePeriod

public TimePeriod(long value,
                  TimePeriod.Unit unit)
Creates instance of time period.

Parameters:
value - value in milliseconds
unit - unit
Method Detail

getValue

public long getValue()
Gets value.

Returns:
value in milliseconds

getValue

public long getValue(Date since)
Gets value.

Parameters:
since - since
Returns:
value in milliseconds

setValue

public void setValue(long value)
Sets value.

Parameters:
value - value in milliseconds

setValue

public void setValue(long value,
                     TimePeriod.Unit unit)
Sets value.

Parameters:
value - value
unit - unit

parseValue

public static TimePeriod parseValue(String value)
                             throws IllegalArgumentException
Parses value into time period.

Parameters:
value - value to parse
Returns:
time period
Throws:
IllegalArgumentException - if unable to parse value

toString

public String toString()
Creates string representation of the object.

Overrides:
toString in class Object
Returns:
string representation of the object

toLocalizedString

public String toLocalizedString(MessageBroker mb)
Converts into localized string.

Parameters:
mb - message broker
Returns:
localized string

Esri Geoportal Server
1.0

Copyright 2011 Environmental Systems Research Institute. All rights reserved. Use is subject to license terms.