01: package com.jat.integration.db.plugin;
02:
03: import java.text.ParseException;
04: import java.text.SimpleDateFormat;
05:
06: import com.jat.core.config.Config;
07: import com.jat.integration.IntegrationException;
08:
09: /**
10: * <p>Title: JAT</p>
11: * <p>Description: </p>
12: * <p>Copyright: Copyright (c) 2004 -2005 Stefano Fratini (stefano.fratini@gmail.com)</p>
13: * <p>Distributed under the terms of the GNU Lesser General Public License, v2.1 or later</p>
14: * @author stf
15: * @version 1.1
16: */
17:
18: public class ConvertStringToDate implements ConverterPlugin {
19:
20: public ConvertStringToDate() throws Exception {
21: sdf = new SimpleDateFormat(Config.getCurrent().getValue(
22: "general", "date_format"));
23: }
24:
25: public Object convert(Object value) throws IntegrationException {
26: try {
27: java.util.Date date = sdf.parse((String) value);
28: return new java.sql.Date(date.getTime());
29: } catch (ParseException ex) {
30: throw new IntegrationException(this .getClass().getName()
31: + "::convert: exception: " + ex);
32: }
33: }
34:
35: private SimpleDateFormat sdf = null;
36: }
|