geonetwork / geonetwork/core-geonetwork

REST API status/search use of ISODate parameters does not respect Z

Open
#5,016 4 comments 0 reactions 0 assignees View on GitHub
stale
Dominant language
Java
Stars
521
Forks
514
Avg merge
6d 13h
Merged PRs (30d)
19

Description

**Describe the bug**

Here is a test case for ISODate Test
```
@Test
public void testZ() throws Exception {
ISODate isoDate = new ISODate("2019-06-01T00:00:00Z");
Instant instant = isoDate.toDate().toInstant();

ZonedDateTime expected =
ZonedDateTime.of(
2019, 6, 1, 0, 0, 0, 0, ZoneId.of("Z").normalized());

assertEquals( expected.toInstant(), instant );
}
```

Fails with:

```
Expected :2019-06-01T00:00:00Z
Actual :2019-06-01T07:00:00.012Z
```

**To Reproduce**

This issues shows up when making REST API calls across time zones:
```
/{portal}/api/0.1/records/status/search?dateFrom=2019-06-01T00:00:00Z
```

If you wish to produce my exact result please run the test with `-Duser.timezone=America/Vancouver', which will generate the 7 hour difference observed in the above unit test result.

Contributor guide

Open the contributing guide

Research direction

Start with the provided ISODate testZ case and the REST status/search entry point using the dateFrom parameter. Reproduce the failure with -Duser.timezone=America/Vancouver, then trace how the Z suffix is parsed. Done means the test passes and REST API date parameters preserve the UTC instant.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.