Class TimeUtil


  • @Deprecated
    public final class TimeUtil
    extends java.lang.Object
    Deprecated.
    Use Durations and Timestamps instead.
    Utilities to help create/manipulate Timestamp/Duration
    • Field Detail

      • TIMESTAMP_SECONDS_MIN

        public static final long TIMESTAMP_SECONDS_MIN
        Deprecated.
        See Also:
        Constant Field Values
      • TIMESTAMP_SECONDS_MAX

        public static final long TIMESTAMP_SECONDS_MAX
        Deprecated.
        See Also:
        Constant Field Values
      • DURATION_SECONDS_MIN

        public static final long DURATION_SECONDS_MIN
        Deprecated.
        See Also:
        Constant Field Values
      • DURATION_SECONDS_MAX

        public static final long DURATION_SECONDS_MAX
        Deprecated.
        See Also:
        Constant Field Values
    • Method Detail

      • toString

        @Deprecated
        public static java.lang.String toString​(com.google.protobuf.Timestamp timestamp)
        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.
        Throws:
        java.lang.IllegalArgumentException - if the given timestamp is not in the valid range.
      • parseTimestamp

        @Deprecated
        public static com.google.protobuf.Timestamp parseTimestamp​(java.lang.String value)
                                                            throws java.text.ParseException
        Deprecated.
        Parse from RFC 3339 date string to Timestamp. This method accepts all outputs of toString(Timestamp) 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.
        Throws:
        java.text.ParseException - if parsing fails.
      • toString

        @Deprecated
        public static java.lang.String toString​(com.google.protobuf.Duration duration)
        Convert Duration to string format. The string format will contains 3, 6, or 9 fractional digits depending on the precision required to represent the exact Duration value. For example: "1s", "1.010s", "1.000000100s", "-3.100s" The range that can be represented by Duration is from -315,576,000,000 to +315,576,000,000 inclusive (in seconds).
        Returns:
        The string representation of the given duration.
        Throws:
        java.lang.IllegalArgumentException - if the given duration is not in the valid range.
      • parseDuration

        @Deprecated
        public static com.google.protobuf.Duration parseDuration​(java.lang.String value)
                                                          throws java.text.ParseException
        Deprecated.
        Parse from a string to produce a duration.
        Returns:
        A Duration parsed from the string.
        Throws:
        java.text.ParseException - if parsing fails.
      • createTimestampFromMillis

        @Deprecated
        public static com.google.protobuf.Timestamp createTimestampFromMillis​(long milliseconds)
        Deprecated.
        Create a Timestamp from the number of milliseconds elapsed from the epoch.
      • createDurationFromMillis

        @Deprecated
        public static com.google.protobuf.Duration createDurationFromMillis​(long milliseconds)
        Deprecated.
        Create a Duration from the number of milliseconds.
      • toMillis

        @Deprecated
        public static long toMillis​(com.google.protobuf.Timestamp timestamp)
        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.

      • toMillis

        @Deprecated
        public static long toMillis​(com.google.protobuf.Duration duration)
        Convert a Duration to the number of milliseconds.The result will be rounded towards 0 to the nearest millisecond. E.g., if the duration represents -1 nanosecond, it will be rounded to 0.
      • createTimestampFromMicros

        @Deprecated
        public static com.google.protobuf.Timestamp createTimestampFromMicros​(long microseconds)
        Deprecated.
        Create a Timestamp from the number of microseconds elapsed from the epoch.
      • createDurationFromMicros

        @Deprecated
        public static com.google.protobuf.Duration createDurationFromMicros​(long microseconds)
        Deprecated.
        Create a Duration from the number of microseconds.
      • toMicros

        @Deprecated
        public static long toMicros​(com.google.protobuf.Timestamp timestamp)
        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 millisecond.

      • toMicros

        @Deprecated
        public static long toMicros​(com.google.protobuf.Duration duration)
        Convert a Duration to the number of microseconds.The result will be rounded towards 0 to the nearest microseconds. E.g., if the duration represents -1 nanosecond, it will be rounded to 0.
      • createTimestampFromNanos

        @Deprecated
        public static com.google.protobuf.Timestamp createTimestampFromNanos​(long nanoseconds)
        Deprecated.
        Create a Timestamp from the number of nanoseconds elapsed from the epoch.
      • createDurationFromNanos

        @Deprecated
        public static com.google.protobuf.Duration createDurationFromNanos​(long nanoseconds)
        Deprecated.
        Create a Duration from the number of nanoseconds.
      • getCurrentTime

        @Deprecated
        public static com.google.protobuf.Timestamp getCurrentTime()
        Deprecated.
        Use Timestamps.fromMillis(System.currentTimeMillis()) instead.
        Get the current time.
      • getEpoch

        @Deprecated
        public static com.google.protobuf.Timestamp getEpoch()
        Deprecated.
        Use Timestamps.fromMillis(0) instead.
        Get the epoch.
      • multiply

        public static com.google.protobuf.Duration multiply​(com.google.protobuf.Duration duration,
                                                            double times)
        Deprecated.
      • divide

        public static com.google.protobuf.Duration divide​(com.google.protobuf.Duration duration,
                                                          double value)
        Deprecated.
      • multiply

        public static com.google.protobuf.Duration multiply​(com.google.protobuf.Duration duration,
                                                            long times)
        Deprecated.
      • divide

        public static com.google.protobuf.Duration divide​(com.google.protobuf.Duration duration,
                                                          long times)
        Deprecated.
      • divide

        public static long divide​(com.google.protobuf.Duration d1,
                                  com.google.protobuf.Duration d2)
        Deprecated.
      • remainder

        public static com.google.protobuf.Duration remainder​(com.google.protobuf.Duration d1,
                                                             com.google.protobuf.Duration d2)
        Deprecated.