0

I know it is a bit trivial question but I need some reference. I am developing project in SpringBoot backend and frontend in Angular. I have to store date of birth, plane arrival and departure date. At the moment, I stored it as a String:

@Column(nullable = false, length = 15)
private String dateArrival;

Later in Angular I would make proper validation and set date format. On the other hand, maybe this whould be better practise

@Column(nullable)
@Temporal(TemporalType.TIME)
private Date dateArrival;

What's more, if I would like to sent request via Postman what whould be proper format for Date? As String I have more flexibility.

Cheers

kaktusx22
  • 59
  • 1
  • 1
  • 8

1 Answers1

0

https://angular.io/api/common/DatePipe

check standard supported formats

btw. why you store date as string? you have planty of date classes in java - starting with java.util.Date

using those classes you can compare them in easy way, change, transforming to string and milliseconds since 01.01.1970

String gives you non flexibillity

Damian Pioś
  • 473
  • 2
  • 5
  • Ok, thanks. I will use something like this: @JsonFormat(shape=JsonFormat.Shape.STRING, pattern="dd-MM-yyyy") private Date dateArrival; – kaktusx22 Jun 19 '19 at 10:48