Json request body for time format

50 views Asked by At

I'm working on a Hospital Management System in which I have to create an endpoint to create appointments. I'm having issue with the Json request body for time format:

This is my requestDTO

public record AppointmentRequestDTO(

        @ApiModelProperty(value = "Date of the appointment (format: yyyy-MM-dd)", example = "2023-07-31")
        @JsonDeserialize(using = LocalDateDeserializer.class)
        @JsonFormat(pattern = "yyyy-MM-dd")
        LocalDate date,

        @ApiModelProperty(value = "Time of the appointment (format: HH:mm:ss)", example = "14:30:00")
        @JsonFormat(pattern = "HH:mm:ss")
        @JsonDeserialize(using = LocalTimeDeserializer.class)
        LocalTime time,
        String patientId,
        String staffId,
        String description
) {
}

The Json request body looks like this:

{
  "date": "2023-07-22",
  "time": {
    "hour": 0,
    "minute": 0,
    "second": 0,
    "nano": 0
  },
  "patientId": "string",
  "staffId": "string",
  "description": "string"
}

But I actually want something of this form:

{
  "date": "2023-07-22",
  "time": "HH:mm:ss",
  "patientId": "string",
  "staffId": "string",
  "description": "string"
}
0

There are 0 answers