You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cxf.apache.org by "Dongyi Lin (Jira)" <ji...@apache.org> on 2023/10/11 07:44:00 UTC
[jira] [Closed] (CXF-8942) When OdataParser parses a date-time string to Instant, time is ignored and is always 00:00:00
[ https://issues.apache.org/jira/browse/CXF-8942?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Dongyi Lin closed CXF-8942.
---------------------------
Resolution: Not A Problem
After some more research, I realized that I should have added a properties map about the date-time format so that time will be taken into consideration in parsing.
{code:java}
final Map<String, String> props = new HashMap<>();
props.put("search.date-format", "yyyy-MM-dd'T'HH:mm:ss");
final ODataParser<TopicEntity> oDataParser = new ODataParser<>(BookEntity.class, props);{code}
After this change, everything works as expected. Sorry for the confusion. I will close this issue.
> When OdataParser parses a date-time string to Instant, time is ignored and is always 00:00:00
> ---------------------------------------------------------------------------------------------
>
> Key: CXF-8942
> URL: https://issues.apache.org/jira/browse/CXF-8942
> Project: CXF
> Issue Type: Bug
> Components: JAX-RS
> Affects Versions: 4.0.3
> Reporter: Dongyi Lin
> Priority: Major
>
> Hi,
> I use ODataParser of JAX-RS Search to parse odata filter into SearchCondition, which then accepts JPACriteriaQueryVisitor, to build TypedQuery. However, the parser seems to ignore the time part in a date-time string when the target field is of Java Instant type. The resulting condition always has 00:00:00 in the time part regardless of the input.
> Here is an example with a made-up BookEntity, which contains an Instant field:
>
> {code:java}
> public class BookEntity {
> private int id;
> private Instant publishedDate;
> }
> final String queryFilter = "publishedDate ge '2023-07-01T18:00:00Z'";
> final JPACriteriaQueryVisitor<BookEntity, BookEntity> jpaCriteriaQueryVisitor =
> new JPACriteriaQueryVisitor<>(entityManager, BookEntity.class, BookEntity.class);
> final ODataParser<BookEntity> oDataParser = new ODataParser<>(BookEntity.class);
> final SearchCondition<BookEntity> searchCondition = oDataParser.parse(queryFilter);
> searchCondition.accept(jpaCriteriaQueryVisitor);{code}
>
>
> The resulting property value of the search condition is always 2023-07-01T00:00:00Z regardless of the time value in queryFilter. Could you please help me with this problem?
>
--
This message was sent by Atlassian Jira
(v8.20.10#820010)