/** * Parses two related at-style time specifications and returns corresponding timestamps. For example:<p> * <pre> * long[] t = Util.getTimestamps("end-1d","now"); * </pre> * * @param atStyleTimeSpec1 Starting at-style time specification. For the complete explanation of the syntax * allowed see RRDTool's <code>rrdfetch</code> man page.<p> * @param atStyleTimeSpec2 Ending at-style time specification. For the complete explanation of the syntax * allowed see RRDTool's <code>rrdfetch</code> man page.<p> * @return An array of two longs representing starting and ending timestamp in seconds since epoch. */ public static long[] getTimestamps(String atStyleTimeSpec1, String atStyleTimeSpec2) { TimeSpec timeSpec1 = new TimeParser(atStyleTimeSpec1).parse(); TimeSpec timeSpec2 = new TimeParser(atStyleTimeSpec2).parse(); return TimeSpec.getTimestamps(timeSpec1, timeSpec2); }
/** * Parses at-style time specification and returns the corresponding timestamp. For example:<p> * <pre> * long t = Util.getTimestamp("now-1d"); * </pre> * * @param atStyleTimeSpec at-style time specification. For the complete explanation of the syntax * allowed see RRDTool's <code>rrdfetch</code> man page.<p> * @return timestamp in seconds since epoch. */ public static long getTimestamp(String atStyleTimeSpec) { TimeSpec timeSpec = new TimeParser(atStyleTimeSpec).parse(); return timeSpec.getTimestamp(); }