org.hyperic.util
Class TimeUtil
java.lang.Object
org.hyperic.util.TimeUtil
public class TimeUtil
- extends java.lang.Object
Method Summary |
static long |
getInterval(long begin,
long end,
int points)
|
static long |
parseComplexTime(java.lang.String str,
long baseTime,
boolean futureTime)
Parse times in a 'natural language' fashion. |
static java.lang.String |
toString(long time)
|
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
DATE_FORMAT
public static final java.lang.String DATE_FORMAT
- See Also:
- Constant Field Values
DISPLAY_DATE_FORMAT
public static final java.lang.String DISPLAY_DATE_FORMAT
- See Also:
- Constant Field Values
MILLIS_IN_MINUTE
public static final long MILLIS_IN_MINUTE
- See Also:
- Constant Field Values
MILLIS_IN_HOUR
public static final long MILLIS_IN_HOUR
- See Also:
- Constant Field Values
MILLIS_IN_DAY
public static final long MILLIS_IN_DAY
- See Also:
- Constant Field Values
MILLIS_IN_WEEK
public static final long MILLIS_IN_WEEK
- See Also:
- Constant Field Values
toString
public static java.lang.String toString(long time)
parseComplexTime
public static long parseComplexTime(java.lang.String str,
long baseTime,
boolean futureTime)
throws java.text.ParseException
- Parse times in a 'natural language' fashion. The following
types of times/dates are supported:
'now' - Returns the 'basetime' that is passed in
'now - 1 day' - Returns 1 day prior to the base time
'yesterday' - Returns basetime - 1 day
'tomorrow' - Returns basetime + 1 day
'monday' - Returns the previous monday if futureTime is
set to false, else true
'monday + 12 hours' - Depending on futureTime returns different
mondays at noon
'march + 4 days' - 4 days into March
'3:00' - Parse error -- not enough info
'3:00pm' - Future 3 if futureTime is set
'12/24/02 9:00pm' - Absolute time
- Parameters:
str
- String to parsebaseTime
- Basetime to use when calculating relative
times (i.e. now - 3 days)futureTime
- When there is some ambiguity as to the time,
default to the time in the future. I.e
in the case where someone says, "noon" and
the time is currently 1:00, does he mean
the noon that just passed, or the upcoming noon?
- Returns:
- milliseconds from the epoch representing the parsed time
- Throws:
java.text.ParseException
getInterval
public static long getInterval(long begin,
long end,
int points)
Copyright © 2004-2006 Hyperic, Inc. support@hyperic.net, All Rights Reserved.