class TimeSpan extends ConvertableToDate
The TimeSpan
class represents a duration of time in milliseconds. In this
way, it is similar to the scala.concurrent.Duration
class. It is
mostly used in Lift APIs in similar positions as the Scala Duration
class (for example, in event scheduling).
Unlike in the Lift 2.x series, building a TimeSpan
with a Long
will not
have different behavior depending on the value passed. Any passed Long
will be used as a duration.
Prior to Lift 3.0, TimeSpan
was an amalgam of duration and joda
DateTime
, and allowed conversions between the two. As a result,
operational semantics were poorly defined and it was easy to call a method
that seemed like it should have simple duration semantics but run into
DateTime
semantics that made things more complicated instead.
Lift 3.0 mostly maintains API compatibility with the Lift 2.x series, but
introduces a series of deprecations to indicate places where dangerous
and potentially unclear behavior may occur. Lift 3.1 will maintain API
compatibility with all non-deprecated parts of the TimeSpan
API, but will
remove the deprecated aspects.
For deprecated years and month builders it handle an operations on duration field values. Then it could be used only in to-period implicit conversion.
- Alphabetic
- By Inheritance
- TimeSpan
- ConvertableToDate
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
def
+[B](in: B)(implicit f: (B) ⇒ (TimeHelpers.this)#TimeSpan): (TimeHelpers.this)#TimeSpan
Sums this
TimeSpan
with an object that can be converted to aTimeSpan
.Sums this
TimeSpan
with an object that can be converted to aTimeSpan
. If eitherTimeSpan
represents aDuration
, add theDuration
s directly. If bothTimeSpan
s represents aPeriod
(which is deprecated behavior), adds them usingPeriod
addition.- returns
A
TimeSpan
representing the sum of this span andin
'sTimeSpan
representation.
- Exceptions thrown
UnsupportedOperationException
If only one of the twoTimeSpan
s represents aPeriod
and thatPeriod
has a year or month component (this only occurs if the deprecatedmonths
oryears
builders are used, as month and year lengths in milliseconds are only defined with respect to a reference point, since the length of a month or year can vary)- Note
Adding two
,TimeSpan
s where both were constructed using the deprecatedmonths
oryears
builders will result in aTimeSpan
representing aPeriod
. TheseTimeSpan
s can behave in unexpected ways, including throwing exceptions when their millisecond duration is required.Adding two
TimeSpan
s where one of the two was constructed using the deprecatedmonths
oryears
builders will throw an exception.
-
def
-[B](in: B)(implicit f: (B) ⇒ (TimeHelpers.this)#TimeSpan): (TimeHelpers.this)#TimeSpan
Subtracts an object that can be converted to a
TimeSpan
from thisTimeSpan
.Subtracts an object that can be converted to a
TimeSpan
from thisTimeSpan
. If eitherTimeSpan
represents aDuration
, subtracts theDuration
s directly. If bothTimeSpan
s represents aPeriod
(which is deprecated behavior), subtracts them usingPeriod
subtraction.- returns
A
TimeSpan
representing the sum of this span andin
'sTimeSpan
representation.
- Exceptions thrown
UnsupportedOperationException
If only one of the twoTimeSpan
s represents aPeriod
and thatPeriod
has a year or month component (this only occurs if the deprecatedmonths
oryears
builders are used, as month and year lengths in milliseconds are only defined with respect to a reference point, since the length of a month or year can vary)- Note
Subtracting two
,TimeSpan
s where both were constructed using the deprecatedmonths
oryears
builders will result in aTimeSpan
representing aPeriod
. TheseTimeSpan
s can behave in unexpected ways, including throwing exceptions when their millisecond duration is required.Subtracting two
TimeSpan
s where one of the two was constructed using the deprecatedmonths
oryears
builders will throw an exception.
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(cmp: Any): Boolean
Override the equals method so that
TimeSpan
s can be compared to long, int, Joda-TimeDuration
, andTimeSpan
.Override the equals method so that
TimeSpan
s can be compared to long, int, Joda-TimeDuration
, andTimeSpan
.- Definition Classes
- TimeSpan → AnyRef → Any
- Note
Comparing to a Joda-Time
Period
is also done correctly, but is deprecated.
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
millis: Long
- returns
The amount of milliseconds this
TimeSpan
represents.
- Definition Classes
- TimeSpan → ConvertableToDate
- Exceptions thrown
UnsupportedOperationException
When created by the deprecated months/years builder ( month and year lengths in milliseconds are only defined with respect to a reference point, since the length of a month or year can vary).
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
-
def
plus[B](in: B)(implicit f: (B) ⇒ (TimeHelpers.this)#TimeSpan): (TimeHelpers.this)#TimeSpan
Alias for
+
. -
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
toMillis: Long
- returns
The amount of milliseconds this
TimeSpan
represents.
- Exceptions thrown
UnsupportedOperationException
When created by the deprecated months/years builder (month and year lengths in milliseconds are only defined with respect to a reference point, since the length of a month or year can vary).
-
def
toString(): String
Override the toString method to display a readable amount of time using
TimeSpan.format
Override the toString method to display a readable amount of time using
TimeSpan.format
- Definition Classes
- TimeSpan → AnyRef → Any
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
Deprecated Value Members
-
def
date: Date
Convert to a Java
Date
.Convert to a Java
Date
. The number of milliseconds in theDuration
will be added to the UNIX epoch to create aDate
object.- Annotations
- @deprecated
- Deprecated
(Since version 3.0.0) This method will be removed due to its unclear behavior; use new Date(timeSpan.millis) instead.
-
def
toDate: Date
Convert to a Java
Date
.Convert to a Java
Date
. Synonym ofdate
.- Definition Classes
- TimeSpan → ConvertableToDate
- Annotations
- @deprecated
- Deprecated
(Since version 3.0.0) This method will be removed due to its unclear behavior; use new Date(timeSpan.millis) instead.
-
def
toDateTime: DateTime
Convert to a Joda-Time
DateTime
.Convert to a Joda-Time
DateTime
. The number of milliseconds in theDuration
will be added to the UNIX epoch to create aDateTime
object.- Definition Classes
- TimeSpan → ConvertableToDate
- Annotations
- @deprecated
- Deprecated
(Since version 3.0.0) This method will be removed due to its unclear behavior; use new DateTime(timeSpan.millis) instead.