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 Summary
Constructors Constructor Description DateWithTimeZoneOffset(Date date)
Creates a new date in UTC, to beoutput
withZ
timezone designation.DateWithTimeZoneOffset(Date date, int tzOffsetMinutes)
Creates a new date with timezone offset.DateWithTimeZoneOffset(Date date, TimeZone tz)
Creates a new date with timezone offset.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
equals(Object o)
Date
getDate()
Returns the date.int
getTimeZoneOffsetMinutes()
Returns the time zone offset in minutes relative to UTC.int
hashCode()
boolean
isUTC()
Returnstrue
if the date is in UTC.static DateWithTimeZoneOffset
parseISO8601String(String s)
Parses an ISO 8601 representation inYYYY-MM-DDThh:mm:ss±hh:mm
format.String
toISO8601String()
Returns an ISO 8601 representation inYYYY-MM-DDThh:mm:ssZ
orYYYY-MM-DDThh:mm:ss±hh:mm
formatString
toString()
-
-
-
Constructor Detail
-
DateWithTimeZoneOffset
public DateWithTimeZoneOffset(Date date)
Creates a new date in UTC, to beoutput
withZ
timezone designation.- Parameters:
date
- The date. Must not benull
.
-
DateWithTimeZoneOffset
public DateWithTimeZoneOffset(Date date, int tzOffsetMinutes)
Creates a new date with timezone offset.- Parameters:
date
- The date. Must not benull
.tzOffsetMinutes
- The time zone offset in minutes relative to UTC, zero if none. Must be less than+/- 12 x 60
.
-
DateWithTimeZoneOffset
public DateWithTimeZoneOffset(Date date, TimeZone tz)
Creates a new date with timezone offset.- Parameters:
date
- The date. Must not benull
.tz
- The time zone to determine the time zone offset.
-
-
Method Detail
-
isUTC
public boolean isUTC()
Returnstrue
if the date is in UTC.- Returns:
true
if the date is in UTC, else the time zoneoffset
applies.
-
getTimeZoneOffsetMinutes
public int 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
public String toISO8601String()
Returns an ISO 8601 representation inYYYY-MM-DDThh:mm:ssZ
orYYYY-MM-DDThh:mm:ss±hh:mm
formatExample:
2019-11-01T18:19:43+03:00
- Returns:
- The ISO 8601 representation.
-
parseISO8601String
public static DateWithTimeZoneOffset parseISO8601String(String s) throws ParseException
Parses an ISO 8601 representation inYYYY-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.
-
-