View Javadoc
1   package com.gh.mygreen.xlsmapper.cellconverter.impl;
2   
3   import java.util.Date;
4   
5   import com.gh.mygreen.xlsmapper.Configuration;
6   import com.gh.mygreen.xlsmapper.cellconverter.CellConverter;
7   import com.gh.mygreen.xlsmapper.fieldaccessor.FieldAccessor;
8   
9   /**
10   * {@link java.sql.Date}を処理する{@link CellConverter}を作成するためのファクトリクラス。
11   * 
12   * @version 2.0
13   * @author T.TSUCHIE
14   *
15   */
16  public class SqlDateCellConverterFactory extends AbstractDateCellConverterFactory<java.sql.Date> {
17  
18      @Override
19      public SqlDateCellConverter create(final FieldAccessor field, final Configuration config) {
20          
21          final SqlDateCellConverter cellConverter = new SqlDateCellConverter(field, config, this);
22          setupCellConverter(cellConverter, field, config);
23          
24          return cellConverter;
25          
26      }
27      
28      @Override
29      protected java.sql.Date convertTypeValue(final Date date) {
30          return new java.sql.Date(date.getTime());
31      }
32      
33      /**
34       * {@inheritDoc}
35       * <p>{@code yyyy-MM-dd}の値を返す。</p>
36       */
37      @Override
38      protected String getDefaultJavaPattern() {
39          return "yyyy-MM-dd";
40      }
41      
42      /**
43       * {@inheritDoc}
44       * <p>{@code yyyy-mm-dd}の値を返す。</p>
45       */
46      @Override
47      protected String getDefaultExcelPattern() {
48          return "yyyy-mm-dd";
49      }
50      
51      public class SqlDateCellConverter extends AbstractDateCellConverter<java.sql.Date> {
52          
53          private final SqlDateCellConverterFactory convererFactory;
54          
55          private SqlDateCellConverter(final FieldAccessor field, final Configuration config,
56                  final SqlDateCellConverterFactory convererFactory) {
57              super(field, config);
58              this.convererFactory = convererFactory;
59          }
60          
61          @Override
62          protected java.sql.Date convertTypeValue(final Date value) {
63              return convererFactory.convertTypeValue(value);
64          }
65          
66      }
67      
68  }