public class JDFDuration extends Object implements Comparable<JDFDuration>
Constructor and Description |
---|
JDFDuration()
Allocates a
JDFDuration object and initializes it with 0 |
JDFDuration(double s)
Allocates a
JDFDuration object and initializes it with 's' |
JDFDuration(JDFDate start,
JDFDate end)
creates a duration from two dates; may be negative if start later end
|
JDFDuration(JDFDuration d)
Makes a copy of the
JDFDuration object 'd' |
JDFDuration(long s)
Allocates a
JDFDuration object and initializes it with 's' |
JDFDuration(String strDuration)
Allocates a
JDFDuration object and initializes it with a value of strDuration , represented as a formatted duration string. |
Modifier and Type | Method and Description |
---|---|
double |
addSeconds(double seconds)
add seconds to a duration
|
int |
compareTo(JDFDuration arg0) |
static JDFDuration |
createDuration(String duration)
does some heuristics to create a duration if duration is purely numeric, we guess days
|
boolean |
equals(Object other)
Compares two JDFDuration objects for equality.
|
long |
getDuration()
the duration in seconds
|
String |
getDurationISO()
Format and return the duration set by 'setDuration(int i)' or 'setDurationString(String a_aDuration)' as an ISO conforming String.
|
long |
getDurationMillis()
the duration in milliseconds
|
int |
hashCode()
hashCode: complements equals() to fulfill the equals/hashCode contract
|
boolean |
isLonger(JDFDuration x)
isLess - tests if the duration of this JDFDuration is longer than the duration of the specified JDFDuration.
|
boolean |
isShorter(JDFDuration x)
isShorter - tests if the duration of this JDFDuration is less than the duration of the specified JDFDuration.
|
void |
setDuration(double seconds)
setDuration: sets a duration for
this in seconds, including fractions. |
void |
setDuration(long seconds)
setDuration: sets a duration for
this in seconds. |
boolean |
setDurationISO(String a_aDuration)
Set a duration.
|
String |
toString()
for debug purposes
|
public JDFDuration()
JDFDuration
object and initializes it with 0public JDFDuration(JDFDuration d)
JDFDuration
object 'd'd
- the durationpublic JDFDuration(JDFDate start, JDFDate end)
start
- the starting pointend
- the end pointpublic JDFDuration(double s)
JDFDuration
object and initializes it with 's's
- duration in seconds s may be fractionalpublic JDFDuration(long s)
JDFDuration
object and initializes it with 's's
- duration in seconds spublic JDFDuration(String strDuration) throws DataFormatException
JDFDuration
object and initializes it with a value of strDuration
, represented as a formatted duration string. strDuration
- - formatted durationDataFormatException
- if strDuration is not a valid string representation of JDFDurationpublic static JDFDuration createDuration(String duration)
duration
- public double addSeconds(double seconds)
seconds
- number of seconds to addpublic String toString()
public String getDurationISO()
public boolean setDurationISO(String a_aDuration)
a_aDuration
- formatted duration string 'P1Y2M3DT10H30M'public void setDuration(long seconds)
this
in seconds. This duration is used in multiple classes of the JDF (e.g. Heating time).seconds
- the duration in seconds.public void setDuration(double seconds)
this
in seconds, including fractions. This duration is used in multiple classes of the JDF (e.g. Heating
time).seconds
- the duration in seconds.public long getDuration()
public long getDurationMillis()
public boolean isLonger(JDFDuration x)
x
- the JDFDuration object to compare to this
public boolean isShorter(JDFDuration x)
x
- the JDFDuration object to compare to this
public boolean equals(Object other)
true
if and only if the argument is not null
and is a JDFDuration
object that represents the same
duration, as this object.
public int hashCode()
public int compareTo(JDFDuration arg0)
compareTo
in interface Comparable<JDFDuration>
arg0
- Comparable.compareTo(java.lang.Object)
Copyright © 2018. All rights reserved.