java.lang.Object | ||
↳ | org.joda.time.base.BaseSingleFieldPeriod | |
↳ | org.joda.time.Seconds |
An immutable time period representing a number of seconds.
Seconds
is an immutable period that can only store seconds.
It does not store years, months or hours for example. As such it is a
type-safe way of representing a number of seconds in an application.
The number of seconds is set in the constructor, and may be queried using
getSeconds()
. Basic mathematical operations are provided -
plus()
, minus()
, multipliedBy()
and
dividedBy()
.
Seconds
is thread-safe and immutable.
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
MAX_VALUE | Constant representing the maximum number of seconds that can be stored in this object. | ||||||||||
MIN_VALUE | Constant representing the minimum number of seconds that can be stored in this object. | ||||||||||
ONE | Constant representing one second. | ||||||||||
THREE | Constant representing three seconds. | ||||||||||
TWO | Constant representing two seconds. | ||||||||||
ZERO | Constant representing zero seconds. |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Returns a new instance with the seconds divided by the specified divisor.
| |||||||||||
Gets the duration field type, which is
seconds . | |||||||||||
Gets the period type, which is
seconds . | |||||||||||
Gets the number of seconds that this period represents.
| |||||||||||
Is this seconds instance greater than the specified number of seconds.
| |||||||||||
Is this seconds instance less than the specified number of seconds.
| |||||||||||
Returns a new instance with the specified number of seconds taken away.
| |||||||||||
Returns a new instance with the specified number of seconds taken away.
| |||||||||||
Returns a new instance with the seconds multiplied by the specified scalar.
| |||||||||||
Returns a new instance with the seconds value negated.
| |||||||||||
Creates a new
Seconds by parsing a string in the ISO8601 format 'PTnS'. | |||||||||||
Returns a new instance with the specified number of seconds added.
| |||||||||||
Returns a new instance with the specified number of seconds added.
| |||||||||||
Obtains an instance of
Seconds that may be cached. | |||||||||||
Creates a
Seconds representing the number of whole seconds
between the two specified partial datetimes. | |||||||||||
Creates a
Seconds representing the number of whole seconds
between the two specified datetimes. | |||||||||||
Creates a
Seconds representing the number of whole seconds
in the specified interval. | |||||||||||
Creates a new
Seconds representing the number of complete
standard length seconds in the specified period. | |||||||||||
Converts this period in seconds to a period in days assuming a
24 hour day, 60 minute hour and 60 second minute.
| |||||||||||
Converts this period in seconds to a duration in milliseconds assuming a
24 hour day, 60 minute hour and 60 second minute.
| |||||||||||
Converts this period in seconds to a period in hours assuming a
60 minute hour and 60 second minute.
| |||||||||||
Converts this period in seconds to a period in minutes assuming a
60 second minute.
| |||||||||||
Converts this period in seconds to a period in weeks assuming a
7 day week, 24 hour day, 60 minute hour and 60 second minute.
| |||||||||||
Gets this instance as a String in the ISO8601 duration format.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
org.joda.time.base.BaseSingleFieldPeriod
| |||||||||||
From class
java.lang.Object
| |||||||||||
From interface
java.lang.Comparable
| |||||||||||
From interface
org.joda.time.ReadablePeriod
|
Constant representing the maximum number of seconds that can be stored in this object.
Constant representing the minimum number of seconds that can be stored in this object.
Returns a new instance with the seconds divided by the specified divisor. The calculation uses integer division, thus 3 divided by 2 is 1.
This instance is immutable and unaffected by this method call.
divisor | the amount to divide by, may be negative |
---|
ArithmeticException | if the divisor is zero |
---|
Gets the duration field type, which is seconds
.
Gets the number of seconds that this period represents.
Is this seconds instance greater than the specified number of seconds.
other | the other period, null means zero |
---|
Is this seconds instance less than the specified number of seconds.
other | the other period, null means zero |
---|
Returns a new instance with the specified number of seconds taken away.
This instance is immutable and unaffected by this method call.
seconds | the amount of seconds to take away, may be negative |
---|
ArithmeticException | if the result overflows an int |
---|
Returns a new instance with the specified number of seconds taken away.
This instance is immutable and unaffected by this method call.
seconds | the amount of seconds to take away, may be negative, null means zero |
---|
ArithmeticException | if the result overflows an int |
---|
Returns a new instance with the seconds multiplied by the specified scalar.
This instance is immutable and unaffected by this method call.
scalar | the amount to multiply by, may be negative |
---|
ArithmeticException | if the result overflows an int |
---|
Returns a new instance with the seconds value negated.
ArithmeticException | if the result overflows an int |
---|
Creates a new Seconds
by parsing a string in the ISO8601 format 'PTnS'.
The parse will accept the full ISO syntax of PnYnMnWnDTnHnMnS however only the seconds component may be non-zero. If any other component is non-zero, an exception will be thrown.
periodStr | the period string, null returns zero |
---|
IllegalArgumentException | if the string format is invalid |
---|
Returns a new instance with the specified number of seconds added.
This instance is immutable and unaffected by this method call.
seconds | the amount of seconds to add, may be negative |
---|
ArithmeticException | if the result overflows an int |
---|
Returns a new instance with the specified number of seconds added.
This instance is immutable and unaffected by this method call.
seconds | the amount of seconds to add, may be negative, null means zero |
---|
ArithmeticException | if the result overflows an int |
---|
Obtains an instance of Seconds
that may be cached.
Seconds
is immutable, so instances can be cached and shared.
This factory method provides access to shared instances.
seconds | the number of seconds to obtain an instance for |
---|
Creates a Seconds
representing the number of whole seconds
between the two specified partial datetimes.
The two partials must contain the same fields, for example you can specify
two LocalTime
objects.
start | the start partial date, must not be null |
---|---|
end | the end partial date, must not be null |
IllegalArgumentException | if the partials are null or invalid |
---|
Creates a Seconds
representing the number of whole seconds
between the two specified datetimes.
start | the start instant, must not be null |
---|---|
end | the end instant, must not be null |
IllegalArgumentException | if the instants are null or invalid |
---|
Creates a Seconds
representing the number of whole seconds
in the specified interval.
interval | the interval to extract seconds from, null returns zero |
---|
IllegalArgumentException | if the partials are null or invalid |
---|
Creates a new Seconds
representing the number of complete
standard length seconds in the specified period.
This factory method converts all fields from the period to hours using standardised durations for each field. Only those fields which have a precise duration in the ISO UTC chronology can be converted.
period | the period to get the number of hours from, null returns zero |
---|
IllegalArgumentException | if the period contains imprecise duration values |
---|
Converts this period in seconds to a period in days assuming a 24 hour day, 60 minute hour and 60 second minute.
This method allows you to convert between different types of period. However to achieve this it makes the assumption that all days are 24 hours long, all hours are 60 minutes long and all minutes are 60 seconds long. This is not true when daylight savings is considered and may also not be true for some unusual chronologies. However, it is included as it is a useful operation for many applications and business rules.
Converts this period in seconds to a duration in milliseconds assuming a 24 hour day, 60 minute hour and 60 second minute.
This method allows you to convert from a period to a duration. However to achieve this it makes the assumption that all seconds are 24 hours long, all hours are 60 minutes and all minutes are 60 seconds. This is not true when daylight savings time is considered, and may also not be true for some unusual chronologies. However, it is included as it is a useful operation for many applications and business rules.
Converts this period in seconds to a period in hours assuming a 60 minute hour and 60 second minute.
This method allows you to convert between different types of period. However to achieve this it makes the assumption that all hours are 60 minutes long and all minutes are 60 seconds long. This may not be true for some unusual chronologies. However, it is included as it is a useful operation for many applications and business rules.
Converts this period in seconds to a period in minutes assuming a 60 second minute.
This method allows you to convert between different types of period. However to achieve this it makes the assumption that all minutes are 60 seconds long. This may not be true for some unusual chronologies. However, it is included as it is a useful operation for many applications and business rules.
Converts this period in seconds to a period in weeks assuming a 7 day week, 24 hour day, 60 minute hour and 60 second minute.
This method allows you to convert between different types of period. However to achieve this it makes the assumption that all weeks are 7 days long, all days are 24 hours long, all hours are 60 minutes long and all minutes are 60 seconds long. This is not true when daylight savings time is considered, and may also not be true for some unusual chronologies. However, it is included as it is a useful operation for many applications and business rules.
Gets this instance as a String in the ISO8601 duration format.
For example, "PT4S" represents 4 seconds.