Class DateWithTimeZoneOffset

java.lang.Object
com.nimbusds.oauth2.sdk.util.date.DateWithTimeZoneOffset

public class DateWithTimeZoneOffset extends Object
Date with optional timezone offset. Supports basic ISO 8601 formatting and parsing.
  • Constructor Details

    • DateWithTimeZoneOffset

      Creates a new date in UTC, to be output with Z timezone designation.
      Parameters:
      date - The date. Must not be null.
    • DateWithTimeZoneOffset

      public DateWithTimeZoneOffset(Date date, int tzOffsetMinutes)
      Creates a new date with timezone offset.
      Parameters:
      date - The date. Must not be null.
      tzOffsetMinutes - The time zone offset in minutes relative to UTC, zero if none. Must be less than +/- 12 x 60.
    • DateWithTimeZoneOffset

      Creates a new date with timezone offset.
      Parameters:
      date - The date. Must not be null.
      tz - The time zone to determine the time zone offset.
  • Method Details

    • getDate

      public Date getDate()
      Returns the date.
      Returns:
      The date.
    • isUTC

      public boolean isUTC()
      Returns true if the date is in UTC.
      Returns:
      true if the date is in UTC, else the time zone offset applies.
    • getTimeZoneOffsetMinutes

      Returns the time zone offset in minutes relative to UTC.
      Returns:
      The time zone offset in minutes relative to UTC, zero if none.
    • toISO8601String

      Returns an ISO 8601 representation in YYYY-MM-DDThh:mm:ssZ or YYYY-MM-DDThh:mm:ss±hh:mm format

      Example: 2019-11-01T18:19:43+03:00

      Returns:
      The ISO 8601 representation.
    • toString

      public String toString()
      Overrides:
      toString in class Object
    • equals

      public boolean equals(Object o)
      Overrides:
      equals in class Object
    • hashCode

      public int hashCode()
      Overrides:
      hashCode in class Object
    • parseISO8601String

      Parses an ISO 8601 representation in YYYY-MM-DDThh:mm:ss±hh:mm format.

      Example: 2019-11-01T18:19:43+03:00

      Parameters:
      s - The string to parse.
      Returns:
      The date with timezone offset.
      Throws:
      ParseException - If parsing failed.