A Timestamp represents a point in time independent of any time zone orcalendar, represented as seconds and fractions of seconds at nanosecondresolution in UTC Epoch time.
It is encoded using the Proleptic GregorianCalendar which extends the Gregorian calendar backwards to year one. It isencoded assuming all minutes are 60 seconds long, i.e. leap seconds are"smeared" so that no leap second table is needed for interpretation. Range isfrom 0001-01-01T00:00:00Z to 9999-12-31T23:59:59.999999999Z.
Index
Constructors
Properties
Methods
Constructors
constructor
- new
Timestamp(seconds: number, nanoseconds: number):Timestamp Creates a new timestamp.
Parameters
seconds:number
The number of seconds of UTC time since Unix epoch1970-01-01T00:00:00Z. Must be from 0001-01-01T00:00:00Z to9999-12-31T23:59:59Z inclusive.
nanoseconds:number
The non-negative fractions of a second at nanosecondresolution. Negative second values with fractions must still havenon-negative nanoseconds values that count forward in time. Must befrom 0 to 999,999,999 inclusive.
ReturnsTimestamp
Properties
nanoseconds
seconds
Methods
isEqual
toDate
- to
Date():Date Convert a Timestamp to a JavaScript
Dateobject. This conversion causesa loss of precision sinceDateobjects only support millisecond precision.ReturnsDate
JavaScript
Dateobject representing the same point in time asthisTimestamp, with millisecond precision.
toMillis
- to
Millis():number Convert a timestamp to a numeric timestamp (in milliseconds since epoch).This operation causes a loss of precision.
Returnsnumber
The point in time corresponding to this timestamp, represented asthe number of milliseconds since Unix epoch 1970-01-01T00:00:00Z.
valueOf
- value
Of():string Converts this object to a primitive string, which allows Timestamp objects to be comparedusing the
>,<=,>=and>operators.Returnsstring
Static fromDate
Static fromMillis
Static now
Except as otherwise noted, the content of this page is licensed under theCreative Commons Attribution 4.0 License, and code samples are licensed under theApache 2.0 License. For details, see theGoogle Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2022-07-27 UTC.