Jive Forums API (5.5.20.2-oracle) Developer Javadocs

com.jivesoftware.util
Class TimeFormat

java.lang.Object
  extended by com.jivesoftware.util.TimeFormat

public class TimeFormat
extends java.lang.Object

A simple formatter for times. This formatter accepts a long time value (milliseconds) and optionally a style preference and returns a human-readable String representing the time.

By default the time is formatted using a the MEDIUM style. There are 2 other styles to choose from:

Note: this class is not i18n'd.


Field Summary
static int LONG
          Constant for long styles.
static int MEDIUM
          Constant for medium styles.
static int SHORT
          Constant for short styles.
 
Constructor Summary
TimeFormat()
           
 
Method Summary
static java.lang.String format(long time, int style, java.util.Locale locale)
          Formats the millisecond value using the specified style.
static java.lang.String format(long time, java.util.Locale locale)
          Formats the millisecond value with a style of MEDIUM.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SHORT

public static final int SHORT
Constant for short styles.

See Also:
Constant Field Values

MEDIUM

public static final int MEDIUM
Constant for medium styles.

See Also:
Constant Field Values

LONG

public static final int LONG
Constant for long styles.

See Also:
Constant Field Values
Constructor Detail

TimeFormat

public TimeFormat()
Method Detail

format

public static java.lang.String format(long time,
                                      java.util.Locale locale)
Formats the millisecond value with a style of MEDIUM. The given long value must be positive.

Parameters:
time - the millisecond time value to format. Must be positive.
Returns:
a human readable string value of the time.

format

public static java.lang.String format(long time,
                                      int style,
                                      java.util.Locale locale)
Formats the millisecond value using the specified style. If the style is not SHORT, MEDIUM, or LONG then an IllegalArgumentException will be thrown. The given long value must be positive as well.

Parameters:
time - the millisecond time value to format. Must be positive.
style - the desired formatting style.
Returns:
a human readable string value of the time.

Jive Forums Project Page

Copyright © 1999-2006 Jive Software.