Static Public Member Functions | Static Public Attributes | Private Member Functions | Static Private Member Functions | Static Private Attributes | List of all members
com.google.protobuf.util.Timestamps Class Reference

Static Public Member Functions

static Timestamp add (Timestamp start, Duration length)
 
static Duration between (Timestamp from, Timestamp to)
 
static Timestamp checkValid (Timestamp timestamp)
 
static Timestamp checkValid (Timestamp.Builder timestampBuilder)
 
static Comparator< Timestampcomparator ()
 
static int compare (Timestamp x, Timestamp y)
 
static Timestamp fromMicros (long microseconds)
 
static Timestamp fromMillis (long milliseconds)
 
static Timestamp fromNanos (long nanoseconds)
 
static Timestamp fromSeconds (long seconds)
 
static boolean isValid (long seconds, int nanos)
 
static boolean isValid (Timestamp timestamp)
 
static Timestamp parse (String value) throws ParseException
 
static Timestamp subtract (Timestamp start, Duration length)
 
static long toMicros (Timestamp timestamp)
 
static long toMillis (Timestamp timestamp)
 
static long toNanos (Timestamp timestamp)
 
static long toSeconds (Timestamp timestamp)
 
static String toString (Timestamp timestamp)
 

Static Public Attributes

static final Timestamp EPOCH = Timestamp.newBuilder().setSeconds(0).setNanos(0).build()
 
static final Timestamp MAX_VALUE
 
static final Timestamp MIN_VALUE
 

Private Member Functions

 Timestamps ()
 

Static Private Member Functions

static SimpleDateFormat createTimestampFormat ()
 
static long parseTimezoneOffset (String value) throws ParseException
 

Static Private Attributes

static final Comparator< TimestampCOMPARATOR
 
static final ThreadLocal< SimpleDateFormat > timestampFormat
 

Detailed Description

Utilities to help create/manipulate

protobuf/timestamp.proto

. All operations throw an IllegalArgumentException if the input(s) are not {@linkplain isValid(Timestamp) valid}.

Definition at line 54 of file Timestamps.java.

Constructor & Destructor Documentation

◆ Timestamps()

com.google.protobuf.util.Timestamps.Timestamps ( )
inlineprivate

Definition at line 101 of file Timestamps.java.

Member Function Documentation

◆ add()

static Timestamp com.google.protobuf.util.Timestamps.add ( Timestamp  start,
Duration  length 
)
inlinestatic

Add a duration to a timestamp.

Definition at line 370 of file Timestamps.java.

◆ between()

static Duration com.google.protobuf.util.Timestamps.between ( Timestamp  from,
Timestamp  to 
)
inlinestatic

Calculate the difference between two timestamps.

Definition at line 361 of file Timestamps.java.

◆ checkValid() [1/2]

static Timestamp com.google.protobuf.util.Timestamps.checkValid ( Timestamp  timestamp)
inlinestatic

Throws an IllegalArgumentException if the given Timestamp is not valid.

Definition at line 168 of file Timestamps.java.

◆ checkValid() [2/2]

static Timestamp com.google.protobuf.util.Timestamps.checkValid ( Timestamp.Builder  timestampBuilder)
inlinestatic

Builds the given builder and throws an IllegalArgumentException if it is not valid. See checkValid(Timestamp).

Returns
A valid, built Timestamp.

Definition at line 188 of file Timestamps.java.

◆ comparator()

static Comparator<Timestamp> com.google.protobuf.util.Timestamps.comparator ( )
inlinestatic

Returns a Comparator for Timestamps which sorts in increasing chronological order. Nulls and invalid Timestamps are not allowed (see isValid).

Definition at line 119 of file Timestamps.java.

◆ compare()

static int com.google.protobuf.util.Timestamps.compare ( Timestamp  x,
Timestamp  y 
)
inlinestatic

Compares two timestamps. The value returned is identical to what would be returned by:

Timestamps.comparator().compare(x, y)

.

Returns
the value
0
if
x == y
; a value less than
0
if
x < y
; and a value greater than
0
if
x > y

Definition at line 130 of file Timestamps.java.

◆ createTimestampFormat()

static SimpleDateFormat com.google.protobuf.util.Timestamps.createTimestampFormat ( )
inlinestaticprivate

Definition at line 91 of file Timestamps.java.

◆ fromMicros()

static Timestamp com.google.protobuf.util.Timestamps.fromMicros ( long  microseconds)
inlinestatic

Create a Timestamp from the number of microseconds elapsed from the epoch.

Definition at line 325 of file Timestamps.java.

◆ fromMillis()

static Timestamp com.google.protobuf.util.Timestamps.fromMillis ( long  milliseconds)
inlinestatic

Create a Timestamp from the number of milliseconds elapsed from the epoch.

Definition at line 303 of file Timestamps.java.

◆ fromNanos()

static Timestamp com.google.protobuf.util.Timestamps.fromNanos ( long  nanoseconds)
inlinestatic

Create a Timestamp from the number of nanoseconds elapsed from the epoch.

Definition at line 347 of file Timestamps.java.

◆ fromSeconds()

static Timestamp com.google.protobuf.util.Timestamps.fromSeconds ( long  seconds)
inlinestatic

Create a Timestamp from the number of seconds elapsed from the epoch.

Definition at line 286 of file Timestamps.java.

◆ isValid() [1/2]

static boolean com.google.protobuf.util.Timestamps.isValid ( long  seconds,
int  nanos 
)
inlinestatic

Returns true if the given number of seconds and nanos is a valid Timestamp. The

seconds

value must be in the range -62,135,596,800, +253,402,300,799. The

nanos

value must be in the range [0, +999,999,999].

Note: Negative second values with fractional seconds must still have non-negative nanos values that count forward in time.

Definition at line 156 of file Timestamps.java.

◆ isValid() [2/2]

static boolean com.google.protobuf.util.Timestamps.isValid ( Timestamp  timestamp)
inlinestatic

Returns true if the given Timestamp is valid. The

seconds

value must be in the range -62,135,596,800, +253,402,300,799. The

nanos

value must be in the range [0, +999,999,999].

Note: Negative second values with fractional seconds must still have non-negative nanos values that count forward in time.

Definition at line 142 of file Timestamps.java.

◆ parse()

static Timestamp com.google.protobuf.util.Timestamps.parse ( String  value) throws ParseException
inlinestatic

Parse from RFC 3339 date string to Timestamp. This method accepts all outputs of {} and it also accepts any fractional digits (or none) and any offset as long as they fit into nano-seconds precision. Example of accepted format: "1972-01-01T10:00:20.021-05:00"

Returns
A Timestamp parsed from the string.
Exceptions
ParseExceptionif parsing fails.

Definition at line 232 of file Timestamps.java.

◆ parseTimezoneOffset()

static long com.google.protobuf.util.Timestamps.parseTimezoneOffset ( String  value) throws ParseException
inlinestaticprivate

Definition at line 402 of file Timestamps.java.

◆ subtract()

static Timestamp com.google.protobuf.util.Timestamps.subtract ( Timestamp  start,
Duration  length 
)
inlinestatic

Subtract a duration from a timestamp.

Definition at line 379 of file Timestamps.java.

◆ toMicros()

static long com.google.protobuf.util.Timestamps.toMicros ( Timestamp  timestamp)
inlinestatic

Convert a Timestamp to the number of microseconds elapsed from the epoch.

The result will be rounded down to the nearest microsecond. E.g., if the timestamp represents "1969-12-31T23:59:59.999999999Z", it will be rounded to -1 microsecond.

Definition at line 338 of file Timestamps.java.

◆ toMillis()

static long com.google.protobuf.util.Timestamps.toMillis ( Timestamp  timestamp)
inlinestatic

Convert a Timestamp to the number of milliseconds elapsed from the epoch.

The result will be rounded down to the nearest millisecond. E.g., if the timestamp represents "1969-12-31T23:59:59.999999999Z", it will be rounded to -1 millisecond.

Definition at line 316 of file Timestamps.java.

◆ toNanos()

static long com.google.protobuf.util.Timestamps.toNanos ( Timestamp  timestamp)
inlinestatic

Convert a Timestamp to the number of nanoseconds elapsed from the epoch.

Definition at line 354 of file Timestamps.java.

◆ toSeconds()

static long com.google.protobuf.util.Timestamps.toSeconds ( Timestamp  timestamp)
inlinestatic

Convert a Timestamp to the number of seconds elapsed from the epoch.

The result will be rounded down to the nearest second. E.g., if the timestamp represents "1969-12-31T23:59:59.999999999Z", it will be rounded to -1 second.

Definition at line 297 of file Timestamps.java.

◆ toString()

static String com.google.protobuf.util.Timestamps.toString ( Timestamp  timestamp)
inlinestatic

Convert Timestamp to RFC 3339 date string format. The output will always be Z-normalized and uses 3, 6 or 9 fractional digits as required to represent the exact value. Note that Timestamp can only represent time from 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z. See https://www.ietf.org/rfc/rfc3339.txt

Example of generated format: "1972-01-01T10:00:20.021Z"

Returns
The string representation of the given timestamp.
Exceptions
IllegalArgumentExceptionif the given timestamp is not in the valid range.

Definition at line 203 of file Timestamps.java.

Member Data Documentation

◆ COMPARATOR

final Comparator<Timestamp> com.google.protobuf.util.Timestamps.COMPARATOR
staticprivate
Initial value:
=
new Comparator<Timestamp>() {
@Override
public int compare(Timestamp t1, Timestamp t2) {
int secDiff = Long.compare(t1.getSeconds(), t2.getSeconds());
return (secDiff != 0) ? secDiff : Integer.compare(t1.getNanos(), t2.getNanos());
}
}

Definition at line 103 of file Timestamps.java.

◆ EPOCH

final Timestamp com.google.protobuf.util.Timestamps.EPOCH = Timestamp.newBuilder().setSeconds(0).setNanos(0).build()
static

A constant holding the Timestamp of epoch time,

1970-01-01T00:00:00.000000000Z

.

Definition at line 81 of file Timestamps.java.

◆ MAX_VALUE

final Timestamp com.google.protobuf.util.Timestamps.MAX_VALUE
static
Initial value:
=
Timestamp.newBuilder().setSeconds(TIMESTAMP_SECONDS_MAX).setNanos(999999999).build()

A constant holding the maximum valid Timestamp,

9999-12-31T23:59:59.999999999Z

.

Definition at line 75 of file Timestamps.java.

◆ MIN_VALUE

final Timestamp com.google.protobuf.util.Timestamps.MIN_VALUE
static
Initial value:
=
Timestamp.newBuilder().setSeconds(TIMESTAMP_SECONDS_MIN).setNanos(0).build()

A constant holding the minimum valid Timestamp,

0001-01-01T00:00:00Z

.

Definition at line 69 of file Timestamps.java.

◆ timestampFormat

final ThreadLocal<SimpleDateFormat> com.google.protobuf.util.Timestamps.timestampFormat
staticprivate
Initial value:
=
new ThreadLocal<SimpleDateFormat>() {
@Override
protected SimpleDateFormat initialValue() {
}
}

Definition at line 83 of file Timestamps.java.


The documentation for this class was generated from the following file:
Timestamp
Definition: timestamp.pb.h:69
com.google.protobuf.util.Timestamps.createTimestampFormat
static SimpleDateFormat createTimestampFormat()
Definition: Timestamps.java:91
y
GLint y
Definition: glcorearb.h:2768
x
GLint GLenum GLint x
Definition: glcorearb.h:2834
com.google.protobuf.util.Timestamps.checkValid
static Timestamp checkValid(Timestamp timestamp)
Definition: Timestamps.java:168
com.google.protobuf.util.Timestamps.compare
static int compare(Timestamp x, Timestamp y)
Definition: Timestamps.java:130
com.google.protobuf.util.Timestamps.Timestamps
Timestamps()
Definition: Timestamps.java:101


libaditof
Author(s):
autogenerated on Wed May 21 2025 02:07:08