com.clarkparsia.pellet.util
Enum DurationFormat

java.lang.Object
  extended by java.lang.Enum<DurationFormat>
      extended by com.clarkparsia.pellet.util.DurationFormat
All Implemented Interfaces:
java.io.Serializable, java.lang.Comparable<DurationFormat>

public enum DurationFormat
extends java.lang.Enum<DurationFormat>

Description: A simple class to provide various formatting options for durations represented in milliseconds. The durations are displayed in terms of hours, minutes, seconds, and milliseconds.

Author:
Evren Sirin

Enum Constant Summary
FULL
          Format duration in full format.
LONG
          Format duration in long format.
MEDIUM
          Format duration in medium format (no milliseconds).
SHORT
          Format duration in short format (no hours or milliseconds).
 
Method Summary
 java.lang.String format(long durationInMilliseconds)
          Format the given duration in milliseconds according to the style defined by this DurationFormat class.
static DurationFormat valueOf(java.lang.String name)
          Returns the enum constant of this type with the specified name.
static DurationFormat[] values()
          Returns an array containing the constants of this enum type, in the order they are declared.
 
Methods inherited from class java.lang.Enum
compareTo, equals, getDeclaringClass, hashCode, name, ordinal, toString, valueOf
 
Methods inherited from class java.lang.Object
getClass, notify, notifyAll, wait, wait, wait
 

Enum Constant Detail

FULL

public static final DurationFormat FULL
Format duration in full format. Example: 0 hour(s) 2 minute(s) 13 second(s) 572 milliseconds(s)


LONG

public static final DurationFormat LONG
Format duration in long format. Example: 00:02:13.572


MEDIUM

public static final DurationFormat MEDIUM
Format duration in medium format (no milliseconds). Example: 00:02:13


SHORT

public static final DurationFormat SHORT
Format duration in short format (no hours or milliseconds). Example: 00:02

Method Detail

values

public static DurationFormat[] values()
Returns an array containing the constants of this enum type, in the order they are declared. This method may be used to iterate over the constants as follows:
for (DurationFormat c : DurationFormat.values())
    System.out.println(c);

Returns:
an array containing the constants of this enum type, in the order they are declared

valueOf

public static DurationFormat valueOf(java.lang.String name)
Returns the enum constant of this type with the specified name. The string must match exactly an identifier used to declare an enum constant in this type. (Extraneous whitespace characters are not permitted.)

Parameters:
name - the name of the enum constant to be returned.
Returns:
the enum constant with the specified name
Throws:
java.lang.IllegalArgumentException - if this enum type has no constant with the specified name
java.lang.NullPointerException - if the argument is null

format

public java.lang.String format(long durationInMilliseconds)
Format the given duration in milliseconds according to the style defined by this DurationFormat class.

Parameters:
durationInMilliseconds - duration represented in milliseconds
Returns:
duration formatted as a string


Copyright 2010 Clark & Parsia, LLC. All Rights Reserved.