Class TimeUtil

java.lang.Object
org.apache.beam.runners.dataflow.util.TimeUtil

public final class TimeUtil extends 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 Details

    • toCloudTime

      public static String toCloudTime(ReadableInstant instant)
      Converts a ReadableInstant into a Dataflow API time value.
    • fromCloudTime

      public static @Nullable Instant fromCloudTime(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 String toCloudDuration(ReadableDuration duration)
      Converts a ReadableDuration into a Dataflow API duration string.
    • fromCloudDuration

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