com.threerings.util
Class TimeUtil

java.lang.Object
  extended by com.threerings.util.TimeUtil

public class TimeUtil
extends Object

Utility for times.


Field Summary
static byte DAY
          Time unit constant.
static byte HOUR
          Time unit constant.
static byte MILLISECOND
          Time unit constant.
static byte MINUTE
          Time unit constant.
static byte SECOND
          Time unit constant.
 
Constructor Summary
TimeUtil()
           
 
Method Summary
static int elapsedSeconds(long startStamp, long endStamp)
          Returns (in seconds) the time elapsed between the supplied start and end timestamps (which must be in milliseconds).
static String getTimeOrderString(long duration, byte minUnit)
          Get a translatable string specifying the magnitude of the specified duration.
static String getTimeOrderString(long duration, byte minUnit, byte maxUnit)
          Get a translatable string specifying the magnitude of the specified duration, with the units of time bounded between the minimum and maximum specified.
static String getTimeString(long duration, byte minUnit)
          Get a translatable string specifying the duration, down to the minimum granularity.
static String getTimeString(long duration, byte minUnit, boolean roundUp)
          Get a translatable string specifying the duration, down to the minimum granularity.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

MILLISECOND

public static final byte MILLISECOND
Time unit constant.

See Also:
Constant Field Values

SECOND

public static final byte SECOND
Time unit constant.

See Also:
Constant Field Values

MINUTE

public static final byte MINUTE
Time unit constant.

See Also:
Constant Field Values

HOUR

public static final byte HOUR
Time unit constant.

See Also:
Constant Field Values

DAY

public static final byte DAY
Time unit constant.

See Also:
Constant Field Values
Constructor Detail

TimeUtil

public TimeUtil()
Method Detail

elapsedSeconds

public static int elapsedSeconds(long startStamp,
                                 long endStamp)
Returns (in seconds) the time elapsed between the supplied start and end timestamps (which must be in milliseconds). Partial seconds are truncated, not rounded.


getTimeOrderString

public static String getTimeOrderString(long duration,
                                        byte minUnit)
Get a translatable string specifying the magnitude of the specified duration. Results will be between "1 second" and "X hours", with all times rounded to the nearest unit. "0 units" will never be displayed, the minimum is 1.


getTimeOrderString

public static String getTimeOrderString(long duration,
                                        byte minUnit,
                                        byte maxUnit)
Get a translatable string specifying the magnitude of the specified duration, with the units of time bounded between the minimum and maximum specified. "0 units" will never be returned, the minimum is 1.


getTimeString

public static String getTimeString(long duration,
                                   byte minUnit)
Get a translatable string specifying the duration, down to the minimum granularity.


getTimeString

public static String getTimeString(long duration,
                                   byte minUnit,
                                   boolean roundUp)
Get a translatable string specifying the duration, down to the minimum granularity. Normally rounds down to the nearest minUnit, but optionally rounds up.



Copyright © 2012. All Rights Reserved.