Package com.google.protobuf.util
Class TimeUtil
- java.lang.Object
-
- com.google.protobuf.util.TimeUtil
-
@Deprecated public final class TimeUtil extends java.lang.ObjectDeprecated.UseDurationsandTimestampsinstead.Utilities to help create/manipulate Timestamp/Duration
-
-
Field Summary
Fields Modifier and Type Field Description static longDURATION_SECONDS_MAXDeprecated.static longDURATION_SECONDS_MINDeprecated.static longTIMESTAMP_SECONDS_MAXDeprecated.static longTIMESTAMP_SECONDS_MINDeprecated.
-
Method Summary
All Methods Static Methods Concrete Methods Deprecated Methods Modifier and Type Method Description static com.google.protobuf.Durationadd(com.google.protobuf.Duration d1, com.google.protobuf.Duration d2)Deprecated.static com.google.protobuf.Timestampadd(com.google.protobuf.Timestamp start, com.google.protobuf.Duration length)Deprecated.static com.google.protobuf.DurationcreateDurationFromMicros(long microseconds)Deprecated.UseDurations.fromMicros(long)instead.static com.google.protobuf.DurationcreateDurationFromMillis(long milliseconds)Deprecated.UseDurations.fromMillis(long)instead.static com.google.protobuf.DurationcreateDurationFromNanos(long nanoseconds)Deprecated.UseDurations.fromNanos(long)instead.static com.google.protobuf.TimestampcreateTimestampFromMicros(long microseconds)Deprecated.UseTimestamps.fromMicros(long)instead.static com.google.protobuf.TimestampcreateTimestampFromMillis(long milliseconds)Deprecated.UseTimestamps.fromMillis(long)instead.static com.google.protobuf.TimestampcreateTimestampFromNanos(long nanoseconds)Deprecated.UseTimestamps.fromNanos(long)instead.static com.google.protobuf.Durationdistance(com.google.protobuf.Timestamp from, com.google.protobuf.Timestamp to)Deprecated.static com.google.protobuf.Durationdivide(com.google.protobuf.Duration duration, double value)Deprecated.static com.google.protobuf.Durationdivide(com.google.protobuf.Duration duration, long times)Deprecated.static longdivide(com.google.protobuf.Duration d1, com.google.protobuf.Duration d2)Deprecated.static com.google.protobuf.TimestampgetCurrentTime()Deprecated.UseTimestamps.fromMillis(System.currentTimeMillis())instead.static com.google.protobuf.TimestampgetEpoch()Deprecated.UseTimestamps.fromMillis(0)instead.static com.google.protobuf.Durationmultiply(com.google.protobuf.Duration duration, double times)Deprecated.static com.google.protobuf.Durationmultiply(com.google.protobuf.Duration duration, long times)Deprecated.static com.google.protobuf.DurationparseDuration(java.lang.String value)Deprecated.UseDurations.parse(java.lang.String)instead.static com.google.protobuf.TimestampparseTimestamp(java.lang.String value)Deprecated.UseTimestamps.parse(java.lang.String)instead.static com.google.protobuf.Durationremainder(com.google.protobuf.Duration d1, com.google.protobuf.Duration d2)Deprecated.static com.google.protobuf.Durationsubtract(com.google.protobuf.Duration d1, com.google.protobuf.Duration d2)Deprecated.static com.google.protobuf.Timestampsubtract(com.google.protobuf.Timestamp start, com.google.protobuf.Duration length)Deprecated.static longtoMicros(com.google.protobuf.Duration duration)Deprecated.UseDurations.toMicros(com.google.protobuf.Duration)instead.static longtoMicros(com.google.protobuf.Timestamp timestamp)Deprecated.UseTimestamps.toMicros(com.google.protobuf.Timestamp)instead.static longtoMillis(com.google.protobuf.Duration duration)Deprecated.UseDurations.toMillis(com.google.protobuf.Duration)instead.static longtoMillis(com.google.protobuf.Timestamp timestamp)Deprecated.UseTimestamps.toMillis(com.google.protobuf.Timestamp)instead.static longtoNanos(com.google.protobuf.Duration duration)Deprecated.UseDurations.toNanos(com.google.protobuf.Duration)instead.static longtoNanos(com.google.protobuf.Timestamp timestamp)Deprecated.UseTimestamps.toNanos(com.google.protobuf.Timestamp)instead.static java.lang.StringtoString(com.google.protobuf.Duration duration)Deprecated.UseDurations.toString(com.google.protobuf.Duration)instead.static java.lang.StringtoString(com.google.protobuf.Timestamp timestamp)Deprecated.UseTimestamps.toString(com.google.protobuf.Timestamp)instead.
-
-
-
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)
Deprecated.UseTimestamps.toString(com.google.protobuf.Timestamp)instead.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.txtExample 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.ParseExceptionDeprecated.UseTimestamps.parse(java.lang.String)instead.Parse from RFC 3339 date string to Timestamp. This method accepts all outputs oftoString(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)
Deprecated.UseDurations.toString(com.google.protobuf.Duration)instead.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.ParseExceptionDeprecated.UseDurations.parse(java.lang.String)instead.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.UseTimestamps.fromMillis(long)instead.Create a Timestamp from the number of milliseconds elapsed from the epoch.
-
createDurationFromMillis
@Deprecated public static com.google.protobuf.Duration createDurationFromMillis(long milliseconds)
Deprecated.UseDurations.fromMillis(long)instead.Create a Duration from the number of milliseconds.
-
toMillis
@Deprecated public static long toMillis(com.google.protobuf.Timestamp timestamp)
Deprecated.UseTimestamps.toMillis(com.google.protobuf.Timestamp)instead.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)
Deprecated.UseDurations.toMillis(com.google.protobuf.Duration)instead.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.UseTimestamps.fromMicros(long)instead.Create a Timestamp from the number of microseconds elapsed from the epoch.
-
createDurationFromMicros
@Deprecated public static com.google.protobuf.Duration createDurationFromMicros(long microseconds)
Deprecated.UseDurations.fromMicros(long)instead.Create a Duration from the number of microseconds.
-
toMicros
@Deprecated public static long toMicros(com.google.protobuf.Timestamp timestamp)
Deprecated.UseTimestamps.toMicros(com.google.protobuf.Timestamp)instead.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)
Deprecated.UseDurations.toMicros(com.google.protobuf.Duration)instead.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.UseTimestamps.fromNanos(long)instead.Create a Timestamp from the number of nanoseconds elapsed from the epoch.
-
createDurationFromNanos
@Deprecated public static com.google.protobuf.Duration createDurationFromNanos(long nanoseconds)
Deprecated.UseDurations.fromNanos(long)instead.Create a Duration from the number of nanoseconds.
-
toNanos
@Deprecated public static long toNanos(com.google.protobuf.Timestamp timestamp)
Deprecated.UseTimestamps.toNanos(com.google.protobuf.Timestamp)instead.Convert a Timestamp to the number of nanoseconds elapsed from the epoch.
-
toNanos
@Deprecated public static long toNanos(com.google.protobuf.Duration duration)
Deprecated.UseDurations.toNanos(com.google.protobuf.Duration)instead.Convert a Duration to the number of nanoseconds.
-
getCurrentTime
@Deprecated public static com.google.protobuf.Timestamp getCurrentTime()
Deprecated.UseTimestamps.fromMillis(System.currentTimeMillis())instead.Get the current time.
-
getEpoch
@Deprecated public static com.google.protobuf.Timestamp getEpoch()
Deprecated.UseTimestamps.fromMillis(0)instead.Get the epoch.
-
distance
@Deprecated public static com.google.protobuf.Duration distance(com.google.protobuf.Timestamp from, com.google.protobuf.Timestamp to)Deprecated.Calculate the difference between two timestamps.
-
add
@Deprecated public static com.google.protobuf.Timestamp add(com.google.protobuf.Timestamp start, com.google.protobuf.Duration length)Deprecated.Add a duration to a timestamp.
-
subtract
@Deprecated public static com.google.protobuf.Timestamp subtract(com.google.protobuf.Timestamp start, com.google.protobuf.Duration length)Deprecated.Subtract a duration from a timestamp.
-
add
@Deprecated public static com.google.protobuf.Duration add(com.google.protobuf.Duration d1, com.google.protobuf.Duration d2)Deprecated.Add two durations.
-
subtract
@Deprecated public static com.google.protobuf.Duration subtract(com.google.protobuf.Duration d1, com.google.protobuf.Duration d2)Deprecated.Subtract a duration from another.
-
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.
-
-