org.jrobin.core.timespec
Class TimeSpec

java.lang.Object
  extended by org.jrobin.core.timespec.TimeSpec

public class TimeSpec
extends Object

Simple class to represent time obtained by parsing at-style date specification (described in detail on the rrdfetch man page. See javadoc for TimeParser for more information.


Method Summary
static Calendar[] getTimes(TimeSpec spec1, TimeSpec spec2)
          Use this static method to resolve relative time references and obtain the corresponding Calendar objects.
 long getTimestamp()
          Returns the corresponding timestamp (seconds since Epoch).
static long[] getTimestamps(TimeSpec spec1, TimeSpec spec2)
          Use this static method to resolve relative time references and obtain the corresponding timestamps (seconds since epoch).
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getTimestamp

public long getTimestamp()
                  throws RrdException
Returns the corresponding timestamp (seconds since Epoch). Example:

 TimeParser p = new TimeParser("now-1day");
 TimeSpec ts = p.parse();
 System.out.println("Timestamp was: " + ts.getTimestamp();
 

Returns:
Timestamp (in seconds, no milliseconds)
Throws:
RrdException - Thrown if this TimeSpec object does not represent absolute time.

getTimes

public static Calendar[] getTimes(TimeSpec spec1,
                                  TimeSpec spec2)
                           throws RrdException
Use this static method to resolve relative time references and obtain the corresponding Calendar objects. Example:

 TimeParser pStart = new TimeParser("now-1month"); // starting time
 TimeParser pEnd = new TimeParser("start+1week");  // ending time
 TimeSpec specStart = pStart.parse();
 TimeSpec specEnd = pEnd.parse();
 GregorianCalendar[] gc = TimeSpec.getTimes(specStart, specEnd);
 

Parameters:
spec1 - Starting time specification
spec2 - Ending time specification
Returns:
Two element array containing Calendar objects
Throws:
RrdException - Thrown if relative time references cannot be resolved

getTimestamps

public static long[] getTimestamps(TimeSpec spec1,
                                   TimeSpec spec2)
                            throws RrdException
Use this static method to resolve relative time references and obtain the corresponding timestamps (seconds since epoch). Example:

 TimeParser pStart = new TimeParser("now-1month"); // starting time
 TimeParser pEnd = new TimeParser("start+1week");  // ending time
 TimeSpec specStart = pStart.parse();
 TimeSpec specEnd = pEnd.parse();
 long[] ts = TimeSpec.getTimestamps(specStart, specEnd);
 

Parameters:
spec1 - Starting time specification
spec2 - Ending time specification
Returns:
array containing two timestamps (in seconds since epoch)
Throws:
RrdException - Thrown if relative time references cannot be resolved


Copyright 2003-2008. All Rights Reserved.