I tried to write some more data types on Java time API than Jmix core provides. I also thought about suggesting them to the platform team, but tried to implement them ourselves first.
I wrote a class YearMonthDatatype extending AbstractTemporalDatatype<YearMonth>. The Jmix core FormatStrings are limited to a hard coded set of message bundle keys. So I try to load a custom pattern autowiring io.jmix.core.Messages in my datatype implementation. But testing that leads to a unresolvable circular reference:
Error creating bean with name 'core_MessageTools':
Unsatisfied dependency expressed through field 'metadata';
nested exception is org.springframework.beans.factory.BeanCurrentlyInCreationException:
Error creating bean with name 'core_Metadata':
Requested bean is currently in creation: Is there an unresolvable circular reference?
I assume, I cannot autowire messages in datatype implementations - which is just a workaround anyway.
Is there a way to extend io.jmix.core.metamodel.datatype.FormatStrings in a clean and proper way?
Writing a datatype implementation for java.time.MonthDay is even a bit harder because I cannot extend io.jmix.core.metamodel.datatype.impl.AbstractTemporalDatatype.
Is that for a reason, it supports java.time.Temporal but does not java.time.TemporalAccessor ?
The FormatStrings class is not designed for extension. So using Messages in your datatype implementation is a better solution. It’s true that you cannot inject beans into it, because datatypes are initialized too early in the startup process, but you can inject ApplicationContext and then use its getBean() methods to locate any beans.