Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Values.literal does not work for Instant #4104

Open
barthanssens opened this issue Aug 1, 2022 · 4 comments · May be fixed by #4145
Open

Values.literal does not work for Instant #4104

barthanssens opened this issue Aug 1, 2022 · 4 comments · May be fixed by #4145
Assignees
Labels
🐞 bug issue is a bug

Comments

@barthanssens
Copy link
Contributor

Current Behavior

Values.literal(TemporalAccessor value) should allow for an Instant , but Values.literal(Instant.now()) throws an Exception

Exception in thread "main" java.lang.IllegalArgumentException: value <2022-08-01T21:14:38.470534100Z> cannot be represented by an XML Schema date/time datatype
	at org.eclipse.rdf4j.model.base.AbstractLiteral$TemporalAccessorLiteral.<init>(AbstractLiteral.java:712)
	at org.eclipse.rdf4j.model.base.AbstractValueFactory.createLiteral(AbstractValueFactory.java:214)
	at org.eclipse.rdf4j.model.impl.ValidatingValueFactory.createLiteral(ValidatingValueFactory.java:200)
	at org.eclipse.rdf4j.model.util.Values.literal(Values.java:616)
	at org.eclipse.rdf4j.model.util.Values.literal(Values.java:600)

Expected Behavior

A literal with type xsd:dateTime is created

Steps To Reproduce

No response

Version

4.1.0

Are you interested in contributing a solution yourself?

Yes

Anything else?

No response

@barthanssens barthanssens added the 🐞 bug issue is a bug label Aug 1, 2022
@barthanssens barthanssens self-assigned this Aug 1, 2022
@hmottestad hmottestad added this to the 4.1.1 milestone Aug 2, 2022
@barthanssens
Copy link
Contributor Author

Note: unlike e.g. LocalDateTime, an Instant does not support getting year, month, ... ChronoField

@abrokenjester
Copy link
Contributor

@barthanssens we're getting close to doing a 4.1.1 patch release - do you have a timeline on when you hope to put up a fix for this issue? Would be good if we could fit it in.

@hmottestad
Copy link
Contributor

hmottestad commented Aug 28, 2022

Could an easy fix be to do an instanceof check and call .atOffset(ZoneOffset.UTC)?

Or is it that the milliseconds resolution is higher for Instant than for the XML calendar spec?

@barthanssens
Copy link
Contributor Author

Thanks for the heads-up, looking into it tomorrow

Indeed, was thinking about simple instanceof check.

@hmottestad hmottestad modified the milestones: 4.1.1, 4.1.2 Sep 1, 2022
barthanssens added a commit to Fedict/rdf4j that referenced this issue Sep 2, 2022
barthanssens added a commit to Fedict/rdf4j that referenced this issue Sep 2, 2022
barthanssens added a commit to Fedict/rdf4j that referenced this issue Sep 2, 2022
@hmottestad hmottestad modified the milestones: 4.1.2, 4.1.3, 4.1.4 Sep 11, 2022
@barthanssens barthanssens removed this from the 4.2.1 milestone Nov 7, 2022
@github-project-automation github-project-automation bot moved this to 📋 Backlog in RDF4J Planning Jan 3, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug issue is a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants