public final class Durations extends Object
protobuf/duration.proto. All operations throw an
IllegalArgumentException if the input(s) are not valid.| Modifier and Type | Field and Description |
|---|---|
static com.google.protobuf.Duration |
MAX_VALUE
A constant holding the maximum valid
Duration, approximately +10,000 years. |
static com.google.protobuf.Duration |
MIN_VALUE
A constant holding the minimum valid
Duration, approximately -10,000 years. |
| Modifier and Type | Method and Description |
|---|---|
static com.google.protobuf.Duration |
add(com.google.protobuf.Duration d1,
com.google.protobuf.Duration d2)
Add two durations.
|
static com.google.protobuf.Duration |
checkValid(com.google.protobuf.Duration duration)
Throws an
IllegalArgumentException if the given Duration is not valid. |
static Comparator<com.google.protobuf.Duration> |
comparator()
Returns a
Comparator for Durations which sorts in increasing chronological
order. |
static com.google.protobuf.Duration |
fromMicros(long microseconds)
Create a Duration from the number of microseconds.
|
static com.google.protobuf.Duration |
fromMillis(long milliseconds)
Create a Duration from the number of milliseconds.
|
static com.google.protobuf.Duration |
fromNanos(long nanoseconds)
Create a Duration from the number of nanoseconds.
|
static com.google.protobuf.Duration |
fromSeconds(long seconds)
Create a Duration from the number of seconds.
|
static boolean |
isValid(com.google.protobuf.Duration duration)
Returns true if the given
Duration is valid. |
static boolean |
isValid(long seconds,
int nanos)
Returns true if the given number of seconds and nanos is a valid
Duration. |
static com.google.protobuf.Duration |
parse(String value)
Parse from a string to produce a duration.
|
static com.google.protobuf.Duration |
subtract(com.google.protobuf.Duration d1,
com.google.protobuf.Duration d2)
Subtract a duration from another.
|
static long |
toMicros(com.google.protobuf.Duration duration)
Convert a Duration to the number of microseconds.
|
static long |
toMillis(com.google.protobuf.Duration duration)
Convert a Duration to the number of milliseconds.
|
static long |
toNanos(com.google.protobuf.Duration duration)
Convert a Duration to the number of nanoseconds.
|
static long |
toSeconds(com.google.protobuf.Duration duration)
Convert a Duration to the number of seconds.
|
static String |
toString(com.google.protobuf.Duration duration)
Convert Duration to string format.
|
public static final com.google.protobuf.Duration MIN_VALUE
Duration, approximately -10,000 years.public static final com.google.protobuf.Duration MAX_VALUE
Duration, approximately +10,000 years.public static Comparator<com.google.protobuf.Duration> comparator()
Comparator for Durations which sorts in increasing chronological
order. Nulls and invalid Durations are not allowed (see isValid(com.google.protobuf.Duration)).public static boolean isValid(com.google.protobuf.Duration duration)
Duration is valid. The seconds value must be in the
range [-315,576,000,000, +315,576,000,000]. The nanos value must be in the range
[-999,999,999, +999,999,999].
Note: Durations less than one second are represented with a 0 seconds field
and a positive or negative nanos field. For durations of one second or more, a non-zero
value for the nanos field must be of the same sign as the seconds field.
public static boolean isValid(long seconds,
int nanos)
Duration. The seconds value must be in the range [-315,576,000,000, +315,576,000,000]. The nanos
value must be in the range [-999,999,999, +999,999,999].
Note: Durations less than one second are represented with a 0 seconds field
and a positive or negative nanos field. For durations of one second or more, a non-zero
value for the nanos field must be of the same sign as the seconds field.
public static com.google.protobuf.Duration checkValid(com.google.protobuf.Duration duration)
IllegalArgumentException if the given Duration is not valid.public static String toString(com.google.protobuf.Duration duration)
IllegalArgumentException - if the given duration is not in the valid range.public static com.google.protobuf.Duration parse(String value) throws ParseException
ParseException - if parsing fails.public static com.google.protobuf.Duration fromSeconds(long seconds)
public static long toSeconds(com.google.protobuf.Duration duration)
public static com.google.protobuf.Duration fromMillis(long milliseconds)
public static long toMillis(com.google.protobuf.Duration duration)
public static com.google.protobuf.Duration fromMicros(long microseconds)
public static long toMicros(com.google.protobuf.Duration duration)
public static com.google.protobuf.Duration fromNanos(long nanoseconds)
public static long toNanos(com.google.protobuf.Duration duration)
public static com.google.protobuf.Duration add(com.google.protobuf.Duration d1,
com.google.protobuf.Duration d2)
public static com.google.protobuf.Duration subtract(com.google.protobuf.Duration d1,
com.google.protobuf.Duration d2)
Copyright © 2008–2017 Google. All rights reserved.