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
TimeSpanwith an object that can be converted to aTimeSpan.Sums this
TimeSpanwith an object that can be converted to aTimeSpan. If eitherTimeSpanrepresents aDuration, add theDurations directly. If bothTimeSpans represents aPeriod(which is deprecated behavior), adds them usingPeriodaddition.- returns
A
TimeSpanrepresenting the sum of this span andin'sTimeSpanrepresentation.
- Exceptions thrown
UnsupportedOperationExceptionIf only one of the twoTimeSpans represents aPeriodand thatPeriodhas a year or month component (this only occurs if the deprecatedmonthsoryearsbuilders 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
,TimeSpans where both were constructed using the deprecatedmonthsoryearsbuilders will result in aTimeSpanrepresenting aPeriod. TheseTimeSpans can behave in unexpected ways, including throwing exceptions when their millisecond duration is required.Adding two
TimeSpans where one of the two was constructed using the deprecatedmonthsoryearsbuilders 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
TimeSpanfrom thisTimeSpan.Subtracts an object that can be converted to a
TimeSpanfrom thisTimeSpan. If eitherTimeSpanrepresents aDuration, subtracts theDurations directly. If bothTimeSpans represents aPeriod(which is deprecated behavior), subtracts them usingPeriodsubtraction.- returns
A
TimeSpanrepresenting the sum of this span andin'sTimeSpanrepresentation.
- Exceptions thrown
UnsupportedOperationExceptionIf only one of the twoTimeSpans represents aPeriodand thatPeriodhas a year or month component (this only occurs if the deprecatedmonthsoryearsbuilders 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
,TimeSpans where both were constructed using the deprecatedmonthsoryearsbuilders will result in aTimeSpanrepresenting aPeriod. TheseTimeSpans can behave in unexpected ways, including throwing exceptions when their millisecond duration is required.Subtracting two
TimeSpans where one of the two was constructed using the deprecatedmonthsoryearsbuilders 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
TimeSpans can be compared to long, int, Joda-TimeDuration, andTimeSpan.Override the equals method so that
TimeSpans can be compared to long, int, Joda-TimeDuration, andTimeSpan.- Definition Classes
- TimeSpan → AnyRef → Any
- Note
Comparing to a Joda-Time
Periodis 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
TimeSpanrepresents.
- Definition Classes
- TimeSpan → ConvertableToDate
- Exceptions thrown
UnsupportedOperationExceptionWhen 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
TimeSpanrepresents.
- Exceptions thrown
UnsupportedOperationExceptionWhen 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.formatOverride 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 theDurationwill be added to the UNIX epoch to create aDateobject.- 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 theDurationwill be added to the UNIX epoch to create aDateTimeobject.- 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.