Skip to content

Commit

Permalink
TimestampArgument support for RFC 3339
Browse files Browse the repository at this point in the history
Updated the TimestampArgument class to allow it to accept timestamps
in the ISO 8601 format described in RFC 3339.
  • Loading branch information
dirmgr committed Nov 4, 2023
1 parent 42a4d40 commit c93253d
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
6 changes: 6 additions & 0 deletions docs/release-notes.html
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,12 @@ <h3>Version 6.0.11</h3>
<br><br>
</li>

<li>
Updated the TimestampArgument class to allow it to accept timestamps in the ISO
8601 format described in RFC 3339.
<br><br>
</li>

<li>
Updated client-side support for the LDIF export administrative task in the Ping
Identity Directory Server to allow requesting that the server invoke one or more
Expand Down
13 changes: 13 additions & 0 deletions src/com/unboundid/util/args/TimestampArgument.java
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@
* timestamp values. Values may be provided in any of the following formats:
* <UL>
* <LI>Any valid generalized time format.</LI>
* <LI>Any valid ISO 8601 timestamp in the format described in RFC 3339.</LI>
* <LI>A local time zone timestamp in the format YYYYMMDDhhmmss.uuu</LI>
* <LI>A local time zone timestamp in the format YYYYMMDDhhmmss</LI>
* <LI>A local time zone timestamp in the format YYYYMMDDhhmm</LI>
Expand Down Expand Up @@ -370,6 +371,18 @@ public static Date parseTimestamp(@NotNull final String s)
}


// First, try to parse the value as a timestamp formatted in the ISO 8601
// format specified in RFC 3339.
try
{
return StaticUtils.decodeRFC3339Time(s);
}
catch (final Exception e)
{
// This is fine. It just means the value isn't in the RFC 3339 format.
}


// See if the length of the string matches one of the supported local
// formats. If so, get a format string that we can use to parse the value.
final String dateFormatString;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,8 @@ public void testParseTimestamp()
assertNotNull(TimestampArgument.parseTimestamp("201601011234Z"));
assertNotNull(TimestampArgument.parseTimestamp("2016010112Z"));

assertNotNull(TimestampArgument.parseTimestamp("2016-01-01T12:34:56.789Z"));

assertNotNull(TimestampArgument.parseTimestamp("20160101123456.789"));
assertNotNull(TimestampArgument.parseTimestamp("20160101123456"));
assertNotNull(TimestampArgument.parseTimestamp("201601011234"));
Expand Down

0 comments on commit c93253d

Please sign in to comment.