spring-projects / spring-projects/spring-ldap
Support conversion of Generalized Date as String to ZonedDateTime
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 375
- Forks
- 501
- Avg merge
- 6h 4m
- Merged PRs (30d)
- 63
Description
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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with ConversionServiceConverterManager and DefaultObjectDirectoryMapper, then compare the requested behavior with the referenced StringToZonedDateTimeConverter.java example. Check how ODM registers default converters and how custom converters are added; done means String values convert to ZonedDateTime by default and custom registration is simpler without losing the built-in String-to-Name converter.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java, spring
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100