001package ca.cdr.api.model.json; 002 003/* 004 * #%L 005 * Smile CDR - CDR 006 * %% 007 * Copyright (C) 2016 - 2026 Smile CDR, Inc. 008 * %% 009 * All rights reserved. 010 * #L% 011 */ 012 013import org.hl7.fhir.dstu3.model.DateTimeType; 014import tools.jackson.core.JacksonException; 015import tools.jackson.core.JsonParser; 016import tools.jackson.databind.DeserializationContext; 017import tools.jackson.databind.ValueDeserializer; 018 019import java.util.Date; 020 021import static org.apache.commons.lang3.StringUtils.isNotBlank; 022 023public class JsonDateDeserializer extends ValueDeserializer<Date> { 024 025 @Override 026 public Date deserialize(JsonParser theP, DeserializationContext theDeserializationContext) throws JacksonException { 027 String string = theP.getValueAsString(); 028 if (isNotBlank(string)) { 029 return new DateTimeType(string).getValue(); 030 } 031 return null; 032 } 033}