0

I'm working on a Restful Java system that processes entities with time-related fields. The types of these fields are long, in milliseconds. However, the time fields of the Restful calls are of type Instant. What is the best way to make this conversion?

What i'm thinking now is to define "twin" types for entities-with-time-fields, the type of those fields being Instant in these twins. The system will accept calls of those twin types, then will convert them to the system's own types before dispatching the calls to the backend.

But I feel there are more elegant ways.

What's the best way to do this?

ash__999
  • 161
  • 1
  • 1
  • 11

1 Answers1

1

use MapStruct mapper. It's easy to configure

see Mapstruct LocalDateTime to Instant

  • i think i know what you mean! just quickly - is there a "Spring way" of doing this, anything already in Spring without adding a dependency? – ash__999 Feb 26 '20 at 12:16