Datetime Angularjs x Java x Mysql Persistence

Asked

Viewed 78 times

0

I created an application in our company to control the use of certain equipment of our industry. The fact is that there was a need to control the date/time of entry and exit of a product in a certain equipment.

My architecture: Front: HTML + Angular JS / Back: Java (JPA / REST) + Mysql Database

The HTML code:

<div class="col-md-4"><label>Data Final</label>
    <input class="form-control" type="datetime-local" ng-model="lancamento.dataFinal" required>
</div>

In Java, I created the release class with the attribute dataInicial ( private LocalDateTime dataInicial; ) and the get/sets ...

In Wildfly’s LOG he gives the message:

Error: Status:400 Message: com.fasterxml.Jackson.databind.Jsonmappingexception: Can not instantiate value of type [simple type, class java.time.Localdatetime] from String value ('2016-10-06T14:22:00.000Z'); no single-string constructor/Factory method at [Source: io.undertow.Servlet.spec.Servletinputstreamimpl@13718c2; line: 1, column: 25] (through Reference chain: com.controlequalidade.vo.Releases["stardate"])

I tried to use other date formats, convert everything to String for Java, and then instantiate a date object and play in the bank, but no option was accepted. In Mysql the column type is TIMESTAMP.

Attached is the Front (HTML > Controller > Service) and the class Lancamentos java.

  • Which version of Jackson are you using? As far as I know recent versions automatically convert LocalDateTime. The problem is that he is unable to convert an object of this type into String. If you are using an old version, you will have to implement the interface JsonSerializer and specify how to convert the object to string.

  • Good morning Renan! I’m using version 2.8.1 of Jackson. I’ve never used anything related to JSON serialization...

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.