I have developed a rest service with Spring Boot. I want return a json response with the birthday of the user as milliseconds. How to serialize a java.time.LocalDateTime
object to milliseconds ?
My model class:
@Entity(name = "users")
public class User implements Serializable {
@Id
@GeneratedValue
@Column(name = "user_id")
private Long id;
@Column(name = "first_name")
private String firstName;
@Column(name = "last_name")
private String lastName;
@Column(name = "date_of_birth")
private LocalDateTime dateOfBirth;
. . .
}
current response:
{
. . .
"dateOfBirth":[2018,7,25,7,0],
. . .
}
preferred response:
{
. . .
"dateOfBirth": 1532786354419,
. . .
}
Aucun commentaire:
Enregistrer un commentaire