Form Binding support for java 8 type 'LocalDate'

Dear community,

I am posting a form with a input date picker to which I wish to bind a “new” Java-8 type ‘LocalDate’.

Back in version 2.4 it was stated that java 8 types were supported, and yet it didn’t work then. It appears still not to work. Additional code is required to get it to work. i.e., it is possible, but it is certainly not ‘out of the box’. At least, so far as I can tell.

One needs to create a custom Provider, bind it, … register it, etc etc… and it works.
But I had expected that if it (java 8 inbuilt types) were considered working ‘out of the box’ by 2.4, the fact that they weren’t was likely… a bug or … fixes overlooked… and that it would be fixed by 2.6. That seems not the case.

Any idea if one can expect types like this to be really supported in near future versions? While I have it working, it means extra code in my project that, frankly speaking, doesn’t need to be there. Plus it probably confuses/hinders new comers who also assume it is supported.

Best Regards,

Sean

1 Like

Hi @svaens,

Yes, apparently we are missing Formatters for common java.time types. And to extend that, we also should add a module to support Money and Currency API. It is not part of our current roadmap, but since you already have it working for your application, a pull request would be more than welcome.

Best.

1 Like

I will be happy to help!

1 Like

@svaens Are you still interested to help out? If you already have Formatters you could provide via a pull request that would be great!
It should be easy, you can add the formatters in Formats.java and register them in Formatters.java.
You can open a pull request in the Play GitHub repository - I am happy to review!

Thanks!

1 Like

@mkurz Yes, sure. I’m currently on holiday and unable to code. Will be back around 6th of October after which I can do this. I’ll let you know when the pull request is ready.
Thanks!

1 Like

@mkurz - I have created the pull request now. Sorry for the delay. Please review, and let me know if there is something missing which I’ve yet to take care of.

1 Like