Class TimeUtil


  • public final class TimeUtil
    extends java.lang.Object
    A helper class for converting between Dataflow API and SDK time representations.

    Dataflow API times are strings of the form YYYY-MM-dd'T'HH:mm:ss[.nnnn]'Z': that is, RFC 3339 strings with optional fractional seconds and a 'Z' offset.

    Dataflow API durations are strings of the form ['-']sssss[.nnnn]'s': that is, seconds with optional fractional seconds and a literal 's' at the end.

    In both formats, fractional seconds are either three digits (millisecond resolution), six digits (microsecond resolution), or nine digits (nanosecond resolution).

    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static @Nullable org.joda.time.Duration fromCloudDuration​(java.lang.String duration)
      Converts a Dataflow API duration string into a Duration.
      static @Nullable org.joda.time.Instant fromCloudTime​(java.lang.String time)
      Converts a time value received via the Dataflow API into the corresponding Instant.
      static java.lang.String toCloudDuration​(org.joda.time.ReadableDuration duration)
      Converts a ReadableDuration into a Dataflow API duration string.
      static java.lang.String toCloudTime​(org.joda.time.ReadableInstant instant)
      Converts a ReadableInstant into a Dataflow API time value.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • toCloudTime

        public static java.lang.String toCloudTime​(org.joda.time.ReadableInstant instant)
        Converts a ReadableInstant into a Dataflow API time value.
      • fromCloudTime

        public static @Nullable org.joda.time.Instant fromCloudTime​(java.lang.String time)
        Converts a time value received via the Dataflow API into the corresponding Instant.
        Returns:
        the parsed time, or null if a parse error occurs
      • toCloudDuration

        public static java.lang.String toCloudDuration​(org.joda.time.ReadableDuration duration)
        Converts a ReadableDuration into a Dataflow API duration string.
      • fromCloudDuration

        public static @Nullable org.joda.time.Duration fromCloudDuration​(java.lang.String duration)
        Converts a Dataflow API duration string into a Duration.
        Returns:
        the parsed duration, or null if a parse error occurs