org.mmbase.util
Class RelativeTime

java.lang.Object
  extended by org.mmbase.util.RelativeTime

public class RelativeTime
extends Object

This util class contains several methods and constants to manipulate relative time values. The relative time value has to be provided as either one integer value (representing the time in milliseconds), or as a set of time attribute integers (hours,minutes,seconds and milliseconds).

Version:
$Id: RelativeTime.java 41055 2010-02-15 23:59:16Z michiel $
Author:
David V van Zeventer
Application:
SCAN or Tools (INFO, AnnotRel builder)

Constructor Summary
RelativeTime()
           
 
Method Summary
static String convertIntToTime(int timeValue)
          Converts an integer (representing the time in milliseconds) to a string (like "12:42:15.020")
static int convertTimeToInt(int h, int m, int s, int ms)
          Converts the time attribute values to one integer representing the time in milliseconds.
static int convertTimeToInt(String time)
          Converts a string (like "12:42:15.020") to milliseconds
static int getHours(int timeValue)
          Retrieves the amount of hours that are left in the timeValue variable (representing the time in milliseconds).
static int getMillis(int timeValue)
          Retrieves the amount of milliseconds that are left in the timeValue variable (representing the time in milliseconds).
static int getMinutes(int timeValue)
          Retrieves the amount of minutes that are left in the timeValue variable (representing the time in milliseconds).
static int getSeconds(int timeValue)
          Retrieves the amount of seconds that are left in the timeValue variable (representing the time in milliseconds).
static void main(String[] args)
          Entry point for calling this class from commandline.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

RelativeTime

public RelativeTime()
Method Detail

getHours

public static int getHours(int timeValue)
Retrieves the amount of hours that are left in the timeValue variable (representing the time in milliseconds).

Parameters:
timeValue - An integer which holds the relative time value.
Returns:
The amount of hours left.

getMinutes

public static int getMinutes(int timeValue)
Retrieves the amount of minutes that are left in the timeValue variable (representing the time in milliseconds).

Parameters:
timeValue - An integer which holds the relative time value.
Returns:
The amount of minutes left.

getSeconds

public static int getSeconds(int timeValue)
Retrieves the amount of seconds that are left in the timeValue variable (representing the time in milliseconds).

Parameters:
timeValue - An integer which holds the relative time value.
Returns:
The amount of seconds left.

getMillis

public static int getMillis(int timeValue)
Retrieves the amount of milliseconds that are left in the timeValue variable (representing the time in milliseconds).

Parameters:
timeValue - An integer which holds the relative time value.
Returns:
The amount of milliseconds left.

convertIntToTime

public static String convertIntToTime(int timeValue)
Converts an integer (representing the time in milliseconds) to a string (like "12:42:15.020")

Parameters:
timeValue - The amount of time in milliseconds.
Returns:
String containing the amount of time in the "h:m:s.ms" format.

convertTimeToInt

public static int convertTimeToInt(int h,
                                   int m,
                                   int s,
                                   int ms)
Converts the time attribute values to one integer representing the time in milliseconds.

Parameters:
h - The amount of hours
m - The amount of minutes
s - The amount of seconds
ms - The amount of millis
Returns:
The amount of time in milliseconds OR -1 if the timeValue contains negative values.

convertTimeToInt

public static int convertTimeToInt(String time)
Converts a string (like "12:42:15.020") to milliseconds

Parameters:
time - A string which contains the relative time in the format "hours:minutes:seconds.millis"
Returns:
The amount of time in milliseconds OR -1 if one of the time attributes provided is invalid.

main

public static void main(String[] args)
Entry point for calling this class from commandline. For testing



MMBase 2.0-SNAPSHOT - null