techdev-solutions/trackr-backend — pull request #1 by daus-salar (2014-09-15 12:34:34+00:00)
Title: Experiment migration to JSR-310

Hallo Moritz,

my company http://www.carneios.de had also the idea to create a time tracking app like trackr.
After some evaluation we considered a very similar tech stack, but did not start development yet. Also we currently evaluate to use trackr or patch it to our needs, we had created some prototypes.
During this creation of prototypes, we solved some problems using jsr310(java date time api).

In this branch I want to show you our solution by migrating trackr to jsr310. Although I can't test it with the front end since I haven't tried to start an oauth service up to now, all unit tests succeed.

Here a summary of the changes
* Since JPA 2.1 there exists the concept of an converter, see http://docs.oracle.com/javaee/7/api/javax/persistence/Converter.html. Actually it is rather simple to implement, see `package de.techdev.trackr.domain.converter;`. With the `autoApply` option you even get rid of any special annotations on date-time fields.
* To replace the old Date objects I used the following rules:
** Date fields annotated with `@Temporal(DATE)` are converted to fields of type `LocalDate`
** Date fields annotated with `@Temporal(TIME)` are converted to fields of type `LocalTime`
** Date fields annotated with `@Temporal(TIMESTAMP)` are converted to fields of type `Instant`
* To provide a proper json serialization I wrote custom module, see `TimePropertiesToJson`
* For the the http parameter mapping I copied your `DateConverter`. At this point I am not sure whether there is no time ("hh:mm") http parameter in your application, since I haven't write one but all tests pass.

Possible breakage with frontend:
* In ReportResourceTest.java,TravelExpenseResourceTest.java, VacationRequestResourceTest.java you used `new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");` to write the test data to the backend. Unfortunately this isn't compatible with the `DateTimeFormatter.ISO_INSTANT` since the utc sign 'Z' is missing. I don't think this is really a problem but you should know this.

At the end I conclude it is not difficult to and definitely not impossible to use jsr 310 with jpa and spring. But I can agree that a little bit more support by Hibernate and Spring is desirable.

Regards Lars