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

Support conversion of Generalized Date as String to ZonedDateTime #423

Open
kwin opened this issue Oct 12, 2016 · 1 comment
Open

Support conversion of Generalized Date as String to ZonedDateTime #423

kwin opened this issue Oct 12, 2016 · 1 comment

Comments

@kwin
Copy link
Contributor

kwin commented Oct 12, 2016

Even with ODM there is no built-in conversion from the String representation of date values from LDAP to native Date types (see #167).
Please support a conversion from String to ZonedDateTime by default when leveraging ODM.

An example source code for the conversion can be found in https://github.com/vt-middleware/ldaptive/blob/master/beans/src/main/java/org/ldaptive/beans/spring/convert/StringToZonedDateTimeConverter.java.

Currently it is particularly hard to register custom converters with ODM as you have to do something like this

        DefaultObjectDirectoryMapper objectDirectoryMapper = (DefaultObjectDirectoryMapper) ldapTemplate.getObjectDirectoryMapper();
        DefaultConversionService conversionService = new DefaultConversionService();
        conversionService.addConverter(new StringToZonedDateTimeConverter());
        conversionService.addConverter(new ZonedDateTimeToStringConverter());
        conversionService.addConverter(new ConversionServiceConverterManager.StringToNameConverter()); // default converter from string to name
        ConversionServiceConverterManager converterManager = new ConversionServiceConverterManager(conversionService);
        objectDirectoryMapper.setConverterManager(converterManager);

You even to register the built-in string to name converts as the constructor ConversionServiceConverterManager(GenericConversionService conversionService) does not automatically register those.
Maybe at the same time providing a simple way of registering new/custom converters could be simplified.

@kwin kwin changed the title Support conversion of Generalized Date to ZonedDateTime Support conversion of Generalized Date as String to ZonedDateTime Oct 12, 2016
@jzheaux
Copy link
Collaborator

jzheaux commented Oct 2, 2024

Related #633

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

No branches or pull requests

2 participants