converting GMT format String to Datetime in spring boot Java

My Mongo Input Source data is 2020-04-14 00:00:00.0000000 (GMT-04:00), 
Data Type String
Error: Caused by: java.time.format.DateTimeParseException: Text '' could not be parsed at index 0
at java.time.format.DateTimeFormatter.parseResolved0( ~[na:1.8.0_222]

I did:

DateTimeFormatter dateTimeformatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); 
List<RatingTiming> response = repo.findByserviceRequestedTimestampBetween(LocalDateTime.parse(query.getStartvalue(), dateTimeformatter), LocalDateTime.parse(query.getEndvalue(), dateTimeformatter)); :

public interface RatingResponseRepository extends MongoRepository<RatingTiming, String> {
    List<RatingTiming> findByserviceRequestedTimestampBetween(LocalDateTime startDate, LocalDateTime endDate);
} :

(shape = JsonFormat.Shape.STRING, pattern = "yyyy-MM-dd HH:mm:ss'")
@JsonDeserialize(using = DateDeserializer.class)
public LocalDateTime serviceRequestedTimestamp;

Read more here:

Content Attribution

This content was originally published by Bsr at Recent Questions - Stack Overflow, and is syndicated here via their RSS feed. You can read the original post over there.

%d bloggers like this: