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

CoerceUtil cannot convert String/Long to Date field properly #292

Closed
xiaoyao1991 opened this issue Jul 18, 2016 · 5 comments
Closed

CoerceUtil cannot convert String/Long to Date field properly #292

xiaoyao1991 opened this issue Jul 18, 2016 · 5 comments
Assignees
Labels
Milestone

Comments

@xiaoyao1991
Copy link
Contributor

filter[author.creationDate][gt]=1454638927411 will receive an error complaining "InvalidValueException: Invalid value: 1454638927411"

@DennisMcWherter
Copy link
Collaborator

This is typically done by adding custom jackson serializers. Does that approach not work here for some reason?

@Koka
Copy link
Contributor

Koka commented Aug 3, 2016

@DeathByTape I'm afraid it's not true - almost everything is converted with CoerceUtil class wich isn't related to Jackson at all and relies to Apache BeanUtils instead to perform conversion. To provide BeanUtils with new converter you have to do some ugly classloading tricks like this:

private void hackElideDateParser() {
    try {
        Class.forName(CoerceUtil.class.getName());
    } catch (ClassNotFoundException e) {
        throw new RuntimeException(e.getMessage(), e);
    }
    DateConverter dateConverter = new DateConverter();
    dateConverter.setPatterns(new String[]{
            "yyyy-MM-dd",
            "yyyy-MM-dd'T'HH:mm:ss",
            "yyyy-MM-dd'T'HH:mm:ss.SSSX",
    });
    ConvertUtils.register(dateConverter, Date.class);
    ConvertUtils.register(new Base64Converter(), byte[].class);
}

@clayreimann clayreimann added this to the elide-3.0 milestone Aug 4, 2016
@clayreimann
Copy link
Contributor

@DeathByTape @Koka We should provide an easy way to customize how we serialize/deserialize data in elide

@xiaoyao1991 xiaoyao1991 self-assigned this Aug 11, 2016
@xiaoyao1991
Copy link
Contributor Author

@DennisMcWherter
Copy link
Collaborator

DennisMcWherter commented Aug 17, 2016

@clayreimann this can be done via the jackson ObjectMapper. I have added a new constructor to make this more obvious: #317

We should also add this to the docs!

NOTE: This is how we serialize/deserialize which could be independent of type coercion within the system.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants