public class TimeSpec extends Object
TimeParser
for more information.Modifier and Type | Method and Description |
---|---|
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).
|
public long getTimestamp()
TimeParser p = new TimeParser("now-1day"); TimeSpec ts = p.parse(); System.out.println("Timestamp was: " + ts.getTimestamp();
public static Calendar[] getTimes(TimeSpec spec1, TimeSpec spec2)
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 specificationpublic static long[] getTimestamps(TimeSpec spec1, TimeSpec spec2)
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 specificationCopyright © 2015. All rights reserved.