package com.bcxin.ars.rest.util;

import java.text.ParseException;
import java.util.Date;
import java.util.Locale;

import org.springframework.format.Formatter;

import com.bcxin.ars.util.DateUtil;

public class DateFormatter implements Formatter<Date> {  
	  
    @Override  
    public String print(Date object, Locale locale) {  
        return null;  
    }  
  
    @Override  
    public Date parse(String text, Locale locale) throws ParseException {
    	Date date = null;
    	if(text != null && text.trim().length() > 0) {
            try {
                date = DateUtil.systemTime.parse(text);  
            } catch (Exception e) {  
                date = DateUtil.systemDate.parse(text);  
            }  
    	}
    	return date;  
    }  
  
}