Package org.apache.commons.beanutils.converters

Examples of org.apache.commons.beanutils.converters.DateConverter


        registerArrayConverter(Short.class,      new ShortConverter(),      throwException, defaultArraySize);
        registerArrayConverter(String.class,     new StringConverter(),     throwException, defaultArraySize);

        // Other
        registerArrayConverter(Class.class,          new ClassConverter(),        throwException, defaultArraySize);
        registerArrayConverter(java.util.Date.class, new DateConverter(),         throwException, defaultArraySize);
        registerArrayConverter(Calendar.class,       new DateConverter(),         throwException, defaultArraySize);
        registerArrayConverter(File.class,           new FileConverter(),         throwException, defaultArraySize);
        registerArrayConverter(java.sql.Date.class,  new SqlDateConverter(),      throwException, defaultArraySize);
        registerArrayConverter(java.sql.Time.class,  new SqlTimeConverter(),      throwException, defaultArraySize);
        registerArrayConverter(Timestamp.class,      new SqlTimestampConverter(), throwException, defaultArraySize);
        registerArrayConverter(URL.class,            new URLConverter(),          throwException, defaultArraySize);
View Full Code Here


    @Test
    public void atomWithNamespaceParse()
        throws Exception
    {
        // Drive commons-beanutils how to convert dates
        DateConverter dateConverter = new DateConverter();
        dateConverter.setPatterns( new String[] { "yyyy-MM-dd'T'HH:mm" } );
        ConvertUtils.register( dateConverter, Date.class );

        final URL rules = getClass().getResource( "atom-rules.xml" );
        final URL input = getClass().getResource( "atom-content.xml" );
View Full Code Here

            usage();
            System.exit( -1 );
        }

        // Drive commons-beanutils how to convert dates
        DateConverter dateConverter = new DateConverter();
        dateConverter.setPatterns( new String[] { "yyyy-MM-dd'T'HH:mm" } );
        ConvertUtils.register( dateConverter, Date.class );

        String filename = args[0];

        Digester digester = newLoader( new FromAnnotationsRuleModule()
View Full Code Here

            usage();
            System.exit( -1 );
        }

        // Drive commons-beanutils how to convert dates
        DateConverter dateConverter = new DateConverter();
        dateConverter.setPatterns( new String[] { "yyyy-MM-dd'T'HH:mm" } );
        ConvertUtils.register( dateConverter, Date.class );

        String filename = args[0];

        Digester digester = newLoader( new AtomRulesModule() ).newDigester();
View Full Code Here

            public Object convert(Class type, Object value) {
                return "Foo-Converter";
            }
        };

        DateConverter dateConverter = new DateConverter();
        dateConverter.setLocale(Locale.US);

        ConvertUtilsBean utils = new ConvertUtilsBean();
        utils.register(dateConverter, java.util.Date.class);
        utils.register(fooConverter, String.class);
View Full Code Here

  /**
   * 定义日期Converter的格式: yyyy-MM-dd 或 yyyy-MM-dd HH:mm:ss
   */
  private static void registerDateConverter() {
    DateConverter dc = new DateConverter();
    dc.setUseLocaleFormat(true);
    dc.setPatterns(new String[] { "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss" });
    org.apache.commons.beanutils.ConvertUtils.register(dc, Date.class);
  }
View Full Code Here

  /**
   * 定义日期Converter的格式: yyyy-MM-dd 或 yyyy-MM-dd HH:mm:ss
   */
  private static void registerDateConverter() {
    DateConverter dc = new DateConverter();
    dc.setUseLocaleFormat(true);
    dc.setPatterns(new String[] { "yyyy-MM-dd", "yyyy-MM-dd HH:mm:ss" });
    org.apache.commons.beanutils.ConvertUtils.register(dc, Date.class);
  }
View Full Code Here

     * throw an exception when a conversion error occurs, otherwise <code>
     * <code>false</code> if a default value should be used.
     */
    private void registerOther(boolean throwException) {
        register(Class.class,         throwException ? new ClassConverter()        : new ClassConverter(null));
        register(java.util.Date.class, throwException ? new DateConverter()        : new DateConverter(null));
        register(Calendar.class,      throwException ? new CalendarConverter()     : new CalendarConverter(null));
        register(File.class,          throwException ? new FileConverter()         : new FileConverter(null));
        register(java.sql.Date.class, throwException ? new SqlDateConverter()      : new SqlDateConverter(null));
        register(java.sql.Time.class, throwException ? new SqlTimeConverter()      : new SqlTimeConverter(null));
        register(Timestamp.class,     throwException ? new SqlTimestampConverter() : new SqlTimestampConverter(null));
View Full Code Here

        registerArrayConverter(Short.class,      new ShortConverter(),      throwException, defaultArraySize);
        registerArrayConverter(String.class,     new StringConverter(),     throwException, defaultArraySize);

        // Other
        registerArrayConverter(Class.class,          new ClassConverter(),        throwException, defaultArraySize);
        registerArrayConverter(java.util.Date.class, new DateConverter(),         throwException, defaultArraySize);
        registerArrayConverter(Calendar.class,       new DateConverter(),         throwException, defaultArraySize);
        registerArrayConverter(File.class,           new FileConverter(),         throwException, defaultArraySize);
        registerArrayConverter(java.sql.Date.class,  new SqlDateConverter(),      throwException, defaultArraySize);
        registerArrayConverter(java.sql.Time.class,  new SqlTimeConverter(),      throwException, defaultArraySize);
        registerArrayConverter(Timestamp.class,      new SqlTimestampConverter(), throwException, defaultArraySize);
        registerArrayConverter(URL.class,            new URLConverter(),          throwException, defaultArraySize);
View Full Code Here

    ConvertUtils.register(new LongConverter(null), Long.class);
    ConvertUtils.register(new BooleanConverter(null), Boolean.class);

    // FIXME: todo, add support for time. could just make all date fields
    // datetime instead
    DateConverter dateConverter = new DateConverter(null);
    dateConverter.setPattern("yyyy-MM-dd");
    ConvertUtils.register(dateConverter, Date.class);
  }
View Full Code Here

TOP

Related Classes of org.apache.commons.beanutils.converters.DateConverter

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.