com.devexperts.util
Class TimePeriod

java.lang.Object
  extended by com.devexperts.util.TimePeriod
All Implemented Interfaces:
Serializable

public class TimePeriod
extends Object
implements Serializable

Value class for period of time with support for ISO8601 duration format.

See Also:
Serialized Form

Constructor Summary
protected TimePeriod(long value)
           
protected TimePeriod(String value)
           
 
Method Summary
 boolean equals(Object o)
           
 long getNanos()
          Returns value in nanoseconds.
 long getTime()
          Returns value in milliseconds.
 int hashCode()
           
 String toString()
           
static TimePeriod valueOf(long value)
          Returns TimePeriod with value milliseconds.
static TimePeriod valueOf(String value)
          Returns TimePeriod represented with a given string.
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Constructor Detail

TimePeriod

protected TimePeriod(long value)

TimePeriod

protected TimePeriod(String value)
              throws InvalidFormatException
Throws:
InvalidFormatException
Method Detail

valueOf

public static TimePeriod valueOf(long value)
Returns TimePeriod with value milliseconds.

Parameters:
value - value in milliseconds
Returns:
TimePeriod with value milliseconds.

valueOf

public static TimePeriod valueOf(String value)
                          throws InvalidFormatException
Returns TimePeriod represented with a given string.

Allowable format is ISO8601 duration, but there are some simplifications and modifications available:

Parameters:
value - string representation
Returns:
TimePeriod represented with a given string.
Throws:
InvalidFormatException - if cannot parse value

toString

public String toString()
Overrides:
toString in class Object

getTime

public long getTime()
Returns value in milliseconds.

Returns:
value in milliseconds

getNanos

public long getNanos()
Returns value in nanoseconds.

Returns:
value in nanoseconds

equals

public boolean equals(Object o)
Overrides:
equals in class Object

hashCode

public int hashCode()
Overrides:
hashCode in class Object


Copyright © 2013 Devexperts. All Rights Reserved.