public class TimeSpec extends Object
TimeParser
for more information.Modifier and Type | Field and 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 |
Modifier and Type | Method and 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) |
static final int TYPE_ABSOLUTE
static final int TYPE_START
static final int TYPE_END
int type
int year
int month
int day
int hour
int min
int sec
int wday
int dyear
int dmonth
int dday
int dhour
int dmin
int dsec
String dateString
TimeSpec context
TimeSpec(String dateString)
void localtime(long timestamp)
GregorianCalendar getTime() throws RrdException
RrdException
public long getTimestamp() throws RrdException
TimeParser p = new TimeParser("now-1day"); TimeSpec ts = p.parse(); System.out.println("Timestamp was: " + ts.getTimestamp();
RrdException
- Thrown if this TimeSpec object does not represent absolute time.String dump()
public static Calendar[] getTimes(TimeSpec spec1, TimeSpec spec2) throws RrdException
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);
spec1
- Starting time specificationspec2
- Ending time specificationRrdException
- Thrown if relative time references cannot be resolvedpublic static long[] getTimestamps(TimeSpec spec1, TimeSpec spec2) throws RrdException
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);
spec1
- Starting time specificationspec2
- Ending time specificationRrdException
- Thrown if relative time references cannot be resolved