1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Erro ao consulta por hora REST e Spring

Discussion in 'Technology' started by Ronaldo Lopes, Oct 8, 2018.

  1. Estou tentando fazer um consulta via GET passando por parâmetro id, data e hora. Se passar ID e Data, funciona, porém ao passar hora tenho retorno do erro.

    Field error in object 'tagsHourFilter' on field 'horaInicial': rejected value [22:27:02]; codes [typeMismatch.tagsHourFilter.horaInicial,typeMismatch.horaInicial,typeMismatch.java.time.LocalTime,typeMismatch]; arguments [org.springframework.context.support.DefaultMessageSourceResolvable: codes [tagsHourFilter.horaInicial,horaInicial]; arguments []; default message [horaInicial]]; default message [Failed to convert property value of type 'java.lang.String' to required type 'java.time.LocalTime' for property 'horaInicial'; nested exception is org.springframework.core.convert.ConversionFailedException: Failed to convert from type [java.lang.String] to type [@com.fasterxml.jackson.annotation.JsonFormat @org.springframework.format.annotation.DateTimeFormat java.time.LocalTime] for value '22:27:02'; nested exception is java.lang.IllegalArgumentException: Parse attempt failed for value [22:27:02]]

    Consulta GET: localhost:8080/lancamento/search?ids=1,3&dataInicial=2018-10-01&dataFinal=2018-10-03&horaInicial=22:27:02

    Classe Filter:

    @JsonFormat(pattern = "hh:mm:ss")
    @DateTimeFormat(pattern = "hh:mm:ss")
    private LocalTime horaInicial;

    Login To add answer/comment
     

Share This Page