Package org.rrd4j.core.timespec
Class TimeSpec
- java.lang.Object
-
- org.rrd4j.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 forTimeParser
for more information.
-
-
Field Summary
Fields Modifier and Type Field Description (package private) TimeSpec
context
(package private) String
dateString
(package private) int
day
(package private) int
dday
(package private) int
dhour
(package private) int
dmin
(package private) int
dmonth
(package private) int
dsec
(package private) int
dyear
(package private) int
hour
(package private) int
min
(package private) int
month
(package private) int
sec
(package private) int
type
(package private) static int
TYPE_ABSOLUTE
(package private) static int
TYPE_END
(package private) static int
TYPE_START
(package private) int
wday
(package private) int
year
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) String
dump()
(package private) GregorianCalendar
getTime()
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).(package private) void
localtime(long timestamp)
-
-
-
Field Detail
-
TYPE_ABSOLUTE
static final int TYPE_ABSOLUTE
- See Also:
- Constant Field Values
-
TYPE_START
static final int TYPE_START
- See Also:
- Constant Field Values
-
TYPE_END
static final int TYPE_END
- See Also:
- Constant Field Values
-
type
int type
-
year
int year
-
month
int month
-
day
int day
-
hour
int hour
-
min
int min
-
sec
int sec
-
wday
int wday
-
dyear
int dyear
-
dmonth
int dmonth
-
dday
int dday
-
dhour
int dhour
-
dmin
int dmin
-
dsec
int dsec
-
dateString
String dateString
-
context
TimeSpec context
-
-
Constructor Detail
-
TimeSpec
TimeSpec(String dateString)
-
-
Method Detail
-
localtime
void localtime(long timestamp)
-
getTime
GregorianCalendar getTime()
-
getTimestamp
public long getTimestamp()
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)
-
dump
String dump()
-
getTimes
public static Calendar[] getTimes(TimeSpec spec1, TimeSpec spec2)
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 specificationspec2
- Ending time specification- Returns:
- Two element array containing Calendar objects
-
getTimestamps
public static long[] getTimestamps(TimeSpec spec1, TimeSpec spec2)
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 specificationspec2
- Ending time specification- Returns:
- array containing two timestamps (in seconds since epoch)
-
-