JadiraOrg/jadira — pull request #17 by gkopff (2014-05-25 03:41:27+00:00)
Title: Use the formatter for outputting values so that the format is guaranteed to be parseable.

Without this fix, the following code fails:

````
import org.jadira.usertype.dateandtime.threeten.columnmapper.StringColumnLocalDateTimeMapper;

final OffsetDateTime withZeroSeconds = OffsetDateTime.now().withSecond(0).withNano(0);
final LocalDateTime localDateTime = withZeroSeconds.toLocalDateTime();
final String truncated = localDateTime.toString();
final LocalDateTime reconst = LocalDateTime.parse(truncated, StringColumnLocalDateTimeMapper.DATETIME_FORMATTER);
````

The reason is that LocalDateTime.toString() truncates zeros. For example,
the time `12:34:00.000` would be output as simply `12:34` by `LocalDateTime.toString()`.

When using the explicit format in the reciprocal parse routine, it fails.

Note that if you don't specify an explicit format, `LocalDateTime.parse(String)`
is able to parse the result successfully.

I note that the test `TestPersistentOffsetDateTimeAsStringAndStringOffset` uses an example `OffsetDateTime` with the seconds and milliseconds fields set. I believe that if those were set to zero, the test would fail. (I didn't verify this myself, as I couldn't build the project out-of-the-box, I think due to requiring various versions of JDKs).