neblaz
neblaz

Reputation: 733

JHipster - Date set on creation or modification of entity in front end is null

Having an example entity

entity Contract {
id    Long,
date1 ZonedDateTime,
date2 ZonedDateTime
}

when creating or modifying an entity of this type in the front end (Angular 4), there is some kind of date picker provided to pick a date. While in the gui dialog the picked date is shown in the input field, but after save is clicked, the field for the date is empty.

In the terminal windows the log output shows something like:

....aop.logging.LoggingAspect     : Enter: ....web.rest.ContractResource.updateContract() with argument[s] = [Contract{id=1054, date1='null', date2='null'}]

....web.rest.ContractResource     : REST request to update Contract : Contract{id=1054, date1='null', date2='null'}

Is this a bug in the front end regarding the date type?

Also, there is an information regarding date type at JHipster (): "ZonedDateTime: A java.time.ZonedDateTime object, used to represent a local date-time in a given timezone (typically a calendar appointment). Note that time zones are neither supported by the REST nor by the persistence layers so you should most probably use Instant instead."

Shall therefore ZonedDateTime be avoided, and Instant used instead? Has that something to do with the above described behavior?

Upvotes: 1

Views: 643

Answers (1)

neblaz
neblaz

Reputation: 733

It looks like it is not enough to just select a date value, one has to provide also time value, when using ZonedDateTime. Then it will be saved correctly.

But still don't understand the given information about the ZonedDateTime.

When creating the entity via the front end, it gets saved into the database correctly, and that happens via REST, I believe.

Upvotes: 1

Related Questions