Packages

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.

Linear Supertypes
Ordering
  1. Alphabetic
  2. By Inheritance
Inherited
  1. TimeSpan
  2. ConvertableToDate
  3. AnyRef
  4. Any
  1. Hide All
  2. Show All
Visibility
  1. Public
  2. All

Instance Constructors

  1. new TimeSpan(ms: Long)
  2. new TimeSpan(dt: Either[Duration, Period])

Value Members

  1. final def !=(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  2. final def ##(): Int
    Definition Classes
    AnyRef → Any
  3. def +[B](in: B)(implicit f: (B) ⇒ (TimeHelpers.this)#TimeSpan): (TimeHelpers.this)#TimeSpan

    Sums this TimeSpan with an object that can be converted to a TimeSpan.

    Sums this TimeSpan with an object that can be converted to a TimeSpan. If either TimeSpan represents a Duration, add the Durations directly. If both TimeSpans represents a Period (which is deprecated behavior), adds them using Period addition.

    returns

    A TimeSpan representing the sum of this span and in's TimeSpan representation.

    Exceptions thrown

    UnsupportedOperationException If only one of the two TimeSpans represents a Period and that Period has a year or month component (this only occurs if the deprecated months or years 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 TimeSpans where both were constructed using the deprecated months or years builders will result in a TimeSpan representing a Period. These TimeSpans 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 deprecated months or years builders will throw an exception.

  4. def -[B](in: B)(implicit f: (B) ⇒ (TimeHelpers.this)#TimeSpan): (TimeHelpers.this)#TimeSpan

    Subtracts an object that can be converted to a TimeSpan from this TimeSpan.

    Subtracts an object that can be converted to a TimeSpan from this TimeSpan. If either TimeSpan represents a Duration, subtracts the Durations directly. If both TimeSpans represents a Period (which is deprecated behavior), subtracts them using Period subtraction.

    returns

    A TimeSpan representing the sum of this span and in's TimeSpan representation.

    Exceptions thrown

    UnsupportedOperationException If only one of the two TimeSpans represents a Period and that Period has a year or month component (this only occurs if the deprecated months or years 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 TimeSpans where both were constructed using the deprecated months or years builders will result in a TimeSpan representing a Period. These TimeSpans 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 deprecated months or years builders will throw an exception.

  5. final def ==(arg0: Any): Boolean
    Definition Classes
    AnyRef → Any
  6. final def asInstanceOf[T0]: T0
    Definition Classes
    Any
  7. def clone(): AnyRef
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  8. final def eq(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  9. def equals(cmp: Any): Boolean

    Override the equals method so that TimeSpans can be compared to long, int, Joda-Time Duration, and TimeSpan.

    Override the equals method so that TimeSpans can be compared to long, int, Joda-Time Duration, and TimeSpan.

    Definition Classes
    TimeSpan → AnyRef → Any
    Note

    Comparing to a Joda-Time Period is also done correctly, but is deprecated.

  10. def finalize(): Unit
    Attributes
    protected[java.lang]
    Definition Classes
    AnyRef
    Annotations
    @throws( classOf[java.lang.Throwable] )
  11. final def getClass(): Class[_]
    Definition Classes
    AnyRef → Any
  12. def hashCode(): Int
    Definition Classes
    AnyRef → Any
  13. final def isInstanceOf[T0]: Boolean
    Definition Classes
    Any
  14. def millis: Long

    returns

    The amount of milliseconds this TimeSpan represents.

    Definition Classes
    TimeSpanConvertableToDate
    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).

  15. final def ne(arg0: AnyRef): Boolean
    Definition Classes
    AnyRef
  16. final def notify(): Unit
    Definition Classes
    AnyRef
  17. final def notifyAll(): Unit
    Definition Classes
    AnyRef
  18. def plus[B](in: B)(implicit f: (B) ⇒ (TimeHelpers.this)#TimeSpan): (TimeHelpers.this)#TimeSpan

    Alias for +.

  19. final def synchronized[T0](arg0: ⇒ T0): T0
    Definition Classes
    AnyRef
  20. 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).

  21. 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
  22. final def wait(): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  23. final def wait(arg0: Long, arg1: Int): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )
  24. final def wait(arg0: Long): Unit
    Definition Classes
    AnyRef
    Annotations
    @throws( ... )

Deprecated Value Members

  1. def date: Date

    Convert to a Java Date.

    Convert to a Java Date. The number of milliseconds in the Duration will be added to the UNIX epoch to create a Date 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.

  2. def toDate: Date

    Convert to a Java Date.

    Convert to a Java Date. Synonym of date.

    Definition Classes
    TimeSpanConvertableToDate
    Annotations
    @deprecated
    Deprecated

    (Since version 3.0.0) This method will be removed due to its unclear behavior; use new Date(timeSpan.millis) instead.

  3. def toDateTime: DateTime

    Convert to a Joda-Time DateTime.

    Convert to a Joda-Time DateTime. The number of milliseconds in the Duration will be added to the UNIX epoch to create a DateTime object.

    Definition Classes
    TimeSpanConvertableToDate
    Annotations
    @deprecated
    Deprecated

    (Since version 3.0.0) This method will be removed due to its unclear behavior; use new DateTime(timeSpan.millis) instead.

Inherited from ConvertableToDate

Inherited from AnyRef

Inherited from Any

Ungrouped