org.rhq.core.clientapi.util
Class TimeUtil

java.lang.Object
  extended by org.rhq.core.clientapi.util.TimeUtil

public class TimeUtil
extends Object


Field Summary
static String DATE_FORMAT
           
static long MILLIS_IN_DAY
           
static long MILLIS_IN_HOUR
           
static long MILLIS_IN_MINUTE
           
static long MILLIS_IN_WEEK
           
 
Constructor Summary
TimeUtil()
           
 
Method Summary
static long getInterval(long begin, long end, int points)
           
static long parseComplexTime(String str, long baseTime, boolean futureTime)
          Parse times in a 'natural language' fashion.
static String toString(long time)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DATE_FORMAT

public static final String 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
Constructor Detail

TimeUtil

public TimeUtil()
Method Detail

toString

public static String toString(long time)

parseComplexTime

public static long parseComplexTime(String str,
                                    long baseTime,
                                    boolean futureTime)
                             throws 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 parse
baseTime - 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:
ParseException

getInterval

public static long getInterval(long begin,
                               long end,
                               int points)


Copyright © 2008-2009 Red Hat, Inc.. All Rights Reserved.