Skip to content

Commit

Permalink
Prepare for new iteration and update documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
Morten Haraldsen committed Jan 22, 2024
1 parent 0272293 commit 8b8e871
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
12 changes: 6 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,21 @@ W3C [Date and Time Formats](https://www.w3.org/TR/NOTE-datetime) in Java.

## Performance

Your mileage may vary. I've done my best to make sure these tests are as accurate as possible, but please do your own evaluation.
* The second resolution test-string is: `2017-12-21T12:20:45Z`
* The nanosecond-resolution test-string is: `2017-12-21T12:20:45.987654321Z`
TL;DR: 30-100x faster than Java JDK classes.

### Parsing
<img src="doc/parse.png" alt="Performance of parsing">
<img src="https://github.com/ethlo/date-time-wars/blob/main/doc/parse.png?raw=true" alt="Performance of parsing">

### Formatting
<img src="doc/format.png" alt="Performance of formatting">
<img src="https://github.com/ethlo/date-time-wars/blob/main/doc/format.png?raw=true" alt="Performance of formatting">

The details and tests are available in a separate repository, [date-time-wars](https://github.com/ethlo/date-time-wars).

### Raw parsing
If you do not need to have the full verification of `java.time.OffsetDateTime`,
you can use the raw, parsed data through `com.ethlo.time.DateTime` that incurs less overhead.

Here it becomes even more visible how the parser scales with the length of the string that is parsed.
Here it becomes even clearer how the parser scales with the length of the string that is parsed.
<img src="doc/parse_raw.png" alt="Performance of raw parsing">

### Environment
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ limitations under the License.
<groupId>com.ethlo.time</groupId>
<packaging>bundle</packaging>
<artifactId>itu</artifactId>
<version>1.7.7</version>
<version>1.7.8-SNAPSHOT</version>
<name>Internet Time Utility</name>
<description>Very fast date-time parser and formatter - RFC 3339 (ISO 8601 profile) and W3C format
</description>
Expand Down
10 changes: 9 additions & 1 deletion src/test/java/com/ethlo/time/LenientParseTests.java
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,14 @@ public void testParseTimestamp()
assertThat(a.toInstant()).isEqualTo(OffsetDateTime.parse(s).toInstant());
}

@Test
public void testParseYear()
{
final String s = "2018";
final DateTime a = ITU.parseLenient(s);
assertThat(a.toInstant()).isEqualTo(OffsetDateTime.parse(s + "-01-01T00:00:00Z").toInstant());
}

@Test
public void testParseYearMonth()
{
Expand All @@ -67,6 +75,6 @@ public void testParseYearMonthHourMinutes()
{
final String s = "2018-11-27T12:30";
final DateTime a = ITU.parseLenient(s);
assertThat(a.toInstant()).isEqualTo(OffsetDateTime.parse(s + ":00Z").toInstant());
assertThat(a.toInstant()).isEqualTo(OffsetDateTime.parse(s + "Z").toInstant());
}
}

0 comments on commit 8b8e871

Please sign in to comment.