Represents a time format with second and attosecond precision.
This class allows representing time values with a high degree of precision, using seconds and attoseconds (10^-18 seconds) as the units. It provides functionalities for basic arithmetic operations, comparisons, and conversions to and from other time units.
Value parameters
- attoseconds
-
The number of attoseconds. Can be positive, negative, or zero. Must be in the range (-10^18, 10^18).
- seconds
-
The number of seconds. Can be positive, negative, or zero.
Attributes
- Throws
-
IllegalArgumentException
if attoseconds is outside the allowed range. Example usage:
val time1 = new TimeFormat(1, 500000000000000000L) // 1.5 seconds val time2 = new TimeFormat(0, 750000000000000000L) // 0.75 seconds val sum = time1 + time2 // 2.25 seconds val difference = time1 - time2 // 0.75 seconds println(s"Sum: $sum") println(s"Difference: $difference")
- Companion
- object
- Graph
-
- Supertypes
- Known subtypes
-
class AbsoluteTime
Members list
Value members
Constructors
Copy constructor that creates a new TimeFormat instance from an existing one.
Copy constructor that creates a new TimeFormat instance from an existing one.
Value parameters
- tf
-
The TimeFormat instance to copy
Attributes
Concrete methods
Multiplies the time value by a scalar.
Multiplies the time value by a scalar.
Value parameters
- scalar
-
The non-negative scalar value to multiply by
Attributes
- Returns
-
A new TimeFormat instance representing the product
- Throws
-
IllegalArgumentException
if scalar is negative
Adds two TimeFormat instances.
Adds two TimeFormat instances.
Value parameters
- second
-
The TimeFormat instance to add
Attributes
- Returns
-
A new TimeFormat instance representing the sum
Subtracts one TimeFormat instance from another.
Subtracts one TimeFormat instance from another.
Value parameters
- second
-
The TimeFormat instance to subtract
Attributes
- Returns
-
A new TimeFormat instance representing the difference
Divides the time value by a scalar.
Divides the time value by a scalar.
Value parameters
- scalar
-
The positive scalar value to divide by
Attributes
- Returns
-
A new TimeFormat instance representing the quotient
- Throws
-
IllegalArgumentException
if scalar is not positive
Compares this TimeFormat instance with another TimeFormat instance.
Compares this TimeFormat instance with another TimeFormat instance.
Value parameters
- o
-
The TimeFormat instance to compare with
Attributes
- Returns
-
An integer value: - Negative if this instance is less than the other - Zero if they are equal - Positive if this instance is greater than the other
- Definition Classes
-
Comparable
Compares the receiver object (this
) with the argument object (that
) for equivalence.
Compares the receiver object (this
) with the argument object (that
) for equivalence.
Any implementation of this method should be an equivalence relation:
- It is reflexive: for any instance
x
of typeAny
,x.equals(x)
should returntrue
. - It is symmetric: for any instances
x
andy
of typeAny
,x.equals(y)
should returntrue
if and only ify.equals(x)
returnstrue
. - It is transitive: for any instances
x
,y
, andz
of typeAny
ifx.equals(y)
returnstrue
andy.equals(z)
returnstrue
, thenx.equals(z)
should returntrue
.
If you override this method, you should verify that your implementation remains an equivalence relation. Additionally, when overriding this method it is usually necessary to override hashCode
to ensure that objects which are "equal" (o1.equals(o2)
returns true
) hash to the same scala.Int. (o1.hashCode.equals(o2.hashCode)
).
Value parameters
- that
-
the object to compare against this object for equality.
Attributes
- Returns
-
true
if the receiver object is equivalent to the argument;false
otherwise. - Definition Classes
-
Any
Gets the attoseconds component of the time value.
Gets the attoseconds component of the time value.
Attributes
- Returns
-
The number of attoseconds
Gets the seconds component of the time value.
Gets the seconds component of the time value.
Attributes
- Returns
-
The number of seconds
Calculates a hash code value for the object.
Calculates a hash code value for the object.
The default hashing algorithm is platform dependent.
Note that it is allowed for two objects to have identical hash codes (o1.hashCode.equals(o2.hashCode)
) yet not be equal (o1.equals(o2)
returns false
). A degenerate implementation could always return 0
. However, it is required that if two objects are equal (o1.equals(o2)
returns true
) that they have identical hash codes (o1.hashCode.equals(o2.hashCode)
). Therefore, when overriding this method, be sure to verify that the behavior is consistent with the equals
method.
Attributes
- Returns
-
the hash code value for this object.
- Definition Classes
-
Any
Checks if this TimeFormat represents zero time (both seconds and attoseconds are 0).
Checks if this TimeFormat represents zero time (both seconds and attoseconds are 0).
Attributes
- Returns
-
true if the time value is zero, false otherwise
Creates a new TimeFormat instance with the negated values of seconds and attoseconds.
Creates a new TimeFormat instance with the negated values of seconds and attoseconds.
Attributes
- Returns
-
A new TimeFormat instance with negated values
Converts current time format to double, "seconds[.]attoseconds"
Converts current time format to double, "seconds[.]attoseconds"
Attributes
- Returns
-
a double value
Returns a string representation of the time format in the form "seconds.attoseconds" where attoseconds is padded with leading zeros to 18 digits.
Returns a string representation of the time format in the form "seconds.attoseconds" where attoseconds is padded with leading zeros to 18 digits.
Attributes
- Returns
-
A string representation of the time value
- Definition Classes
-
Any