public class Duration extends java.lang.Object implements java.lang.Comparable<Duration>, Immutable
This class allows you to specify durations in a variety of units and get them out in a similar variety without worrying about whether your time is in milliseconds or seconds or fortnights or whatnot. Base storage is in milliseconds. I suppose smaller durations might be interesting to some people.
Copyright 2008 Partner Software, Inc.
DateAndTime,
Date,
Time| Modifier and Type | Field and Description |
|---|---|
static long |
DAYS_TO_MILLIS |
static long |
HOURS_TO_MILLIS |
static double |
MILLIS_TO_DAYS |
static double |
MILLIS_TO_HOURS |
static double |
MILLIS_TO_MINUTES |
static double |
MILLIS_TO_SECONDS |
static long |
MINUTES_TO_MILLIS |
static long |
SECONDS_TO_MILLIS |
| Constructor and Description |
|---|
Duration(java.lang.String value) |
| Modifier and Type | Method and Description |
|---|---|
int |
compareTo(Duration nother) |
boolean |
equals(java.lang.Object nother) |
static Duration |
forDays(double days) |
static Duration |
forHertz(double hertz) |
static Duration |
forHours(double hours) |
static Duration |
forMilliseconds(long millis) |
static Duration |
forMinutes(double minutes) |
static Duration |
forSeconds(double seconds) |
static Duration |
forString(java.lang.String value) |
double |
getDays() |
int |
getDaysPart()
Returns the truncated days amount - useful when breaking
the duration up into hours minutes seconds etc.
|
double |
getHours() |
int |
getHoursPart()
Returns the truncated hours amount - useful when breaking
the duration up into hours minutes seconds etc.
|
long |
getMilliseconds() |
int |
getMillisecondsPart()
Returns the truncated millisecond amount - useful when breaking
the duration up into hours minutes seconds etc.
|
double |
getMinutes() |
int |
getMinutesPart()
Returns the truncated minutes amount - useful when breaking
the duration up into hours minutes seconds etc.
|
double |
getSeconds() |
int |
getSecondsPart()
Returns the truncated seconds amount - useful when breaking
the duration up into hours minutes seconds etc.
|
java.util.Date |
toJavaUtilDate()
Returns this time represented as a
Date object. |
java.lang.String |
toString() |
java.lang.String |
toString(java.lang.String formatString)
Returns a String in the specific format representing the Date.
|
public static final long SECONDS_TO_MILLIS
public static final long MINUTES_TO_MILLIS
public static final long HOURS_TO_MILLIS
public static final long DAYS_TO_MILLIS
public static final double MILLIS_TO_SECONDS
public static final double MILLIS_TO_MINUTES
public static final double MILLIS_TO_HOURS
public static final double MILLIS_TO_DAYS
public static Duration forMilliseconds(long millis)
public static Duration forSeconds(double seconds)
public static Duration forMinutes(double minutes)
public static Duration forHours(double hours)
public static Duration forDays(double days)
public static Duration forString(java.lang.String value)
public static Duration forHertz(double hertz)
public long getMilliseconds()
public double getSeconds()
public double getMinutes()
public double getHours()
public double getDays()
public int getMillisecondsPart()
public int getSecondsPart()
public int getMinutesPart()
public int getHoursPart()
public int getDaysPart()
public java.lang.String toString()
toString in class java.lang.Objectpublic java.lang.String toString(java.lang.String formatString)
public java.util.Date toJavaUtilDate()
Date object.public boolean equals(java.lang.Object nother)
equals in class java.lang.Object