/**
 * Copyright 2008-2009. Chongqing CRun Information Industry Co.,Ltd. All rights reserved. <a>http://www.crunii.com</a>
 */
package com.crunii.micro.common.jackson;

import java.io.IOException;
import java.util.Date;

import com.crunii.micro.common.utils.DateUtil;
import com.fasterxml.jackson.core.JsonParser;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.DeserializationContext;
import com.fasterxml.jackson.databind.deser.std.StdScalarDeserializer;

/**
 * @author 田平 create 2017年10月27日下午4:31:34
 */
public class DateDeserializer extends StdScalarDeserializer<Date> {

	private static final long serialVersionUID = 1L;

	protected DateDeserializer(Class<Date> date) {
		super(date);
	}

	/**
	 * @see com.fasterxml.jackson.databind.JsonDeserializer#deserialize(com.fasterxml.jackson.core.JsonParser, com.fasterxml.jackson.databind.DeserializationContext)
	 */
	@Override
	public Date deserialize(JsonParser p, DeserializationContext ctxt) throws IOException, JsonProcessingException {
		return DateUtil.parse(p.getText());
	}

}
