Examples of DateConverter


Examples of org.jbehave.core.steps.ParameterConverters.DateConverter

        assertThat(list.size(), equalTo(expected.size()));
    }

    @Test
    public void shouldConvertDateWithDefaultFormat() throws ParseException, IntrospectionException {
        ParameterConverter converter = new DateConverter();
        assertThat(converter.accept(Date.class), equalTo(true));
        assertThat(converter.accept(WrongType.class), is(false));
        assertThat(converter.accept(mock(Type.class)), is(false));
        Type type = SomeSteps.methodFor("aMethodWithDate").getGenericParameterTypes()[0];
        String date = "01/01/2010";
        assertThat((Date) converter.convertValue(date, type), equalTo(DateConverter.DEFAULT_FORMAT.parse(date)));
    }
View Full Code Here

Examples of org.jbehave.core.steps.ParameterConverters.DateConverter

    }

    @Test
    public void shouldConvertDateWithCustomFormat() throws ParseException, IntrospectionException {
        DateFormat customFormat = new SimpleDateFormat("yyyy-MM-dd");
        ParameterConverter converter = new DateConverter(customFormat);
        assertThat(converter.accept(Date.class), equalTo(true));
        assertThat(converter.accept(WrongType.class), is(false));
        assertThat(converter.accept(mock(Type.class)), is(false));
        Type type = SomeSteps.methodFor("aMethodWithDate").getGenericParameterTypes()[0];
        String date = "2010-01-01";
        assertThat((Date) converter.convertValue(date, type), equalTo(customFormat.parse(date)));
    }
View Full Code Here

Examples of org.jbehave.core.steps.ParameterConverters.DateConverter

    }

    @Test(expected = ParameterConvertionFailed.class)
    public void shouldFailToConvertDateWithInvalidFormat() throws ParseException, IntrospectionException {
        Type type = SomeSteps.methodFor("aMethodWithDate").getGenericParameterTypes()[0];
        ParameterConverter converter = new DateConverter();
        String date = "dd+MM+yyyy";
        converter.convertValue(date, type);
    }
View Full Code Here

Examples of org.more.convert.convert.DateConverter

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

Examples of org.pdfbox.util.DateConverter

            {
                validDate = validDate && Character.isDigit( strValue.charAt( i ) );
            }
            if( validDate )
            {
                DateConverter converter = new DateConverter();
                try
                {
                    retval = converter.toCalendar( value.getString() );
                }
                catch( IOException e )
                {
                    retval = null;
                }
View Full Code Here

Examples of org.projectforge.xml.stream.converter.DateConverter

  }

  @Test
  public void testIsoDateConverter()
  {
    final DateConverter dateConverter = new DateConverter();
    final ISODateConverter isoDateConverter = new ISODateConverter();
    final PFUserDO cetUser = new PFUserDO();
    cetUser.setTimeZone(DateHelper.EUROPE_BERLIN);
    PFUserContext.setUser(cetUser); // login CET user.
    DateHolder dh = new DateHolder();
    dh.setDate(2010, Calendar.AUGUST, 29, 23, 8, 17, 123);
    assertEquals("1283116097123", dateConverter.toString(dh.getDate()));
    assertEquals("2010-08-29 23:08:17.123", isoDateConverter.toString(dh.getDate()));
    assertEquals("2010-08-29 23:08:17", isoDateConverter.toString(dh.setMilliSecond(0).getDate()));
    assertEquals("2010-08-29 23:08", isoDateConverter.toString(dh.setSecond(0).getDate()));
    assertEquals("2010-08-29 23:00", isoDateConverter.toString(dh.setMinute(0).getDate()));
    assertEquals("2010-08-29", isoDateConverter.toString(dh.setHourOfDay(0).getDate()));
View Full Code Here

Examples of org.skyway.spring.util.databinding.DateConverter

  public ConverterForDate(String pattern){
    this(pattern, TypeConversionUtils.getLocale());
  }
 
  public ConverterForDate(String pattern, Locale locale){
    this.converter = new DateConverter(pattern, locale);
  }
View Full Code Here

Examples of org.soybeanMilk.core.bean.converters.DateConverter

    addConverter(String.class, Short.class, new ShortConverter());
   
    //其他
    addConverter(String.class, java.math.BigDecimal.class, new BigDecimalConverter());
    addConverter(String.class, java.math.BigInteger.class, new BigIntegerConverter());
    addConverter(String.class, java.util.Date.class, new DateConverter());
    addConverter(String.class, java.sql.Date.class, new SqlDateConverter());
    addConverter(String.class, java.sql.Time.class, new SqlTimeConverter());
    addConverter(String.class, java.sql.Timestamp.class, new SqlTimestampConverter());
  }
View Full Code Here

Examples of org.springframework.shell.converters.DateConverter

    return new CharacterConverter();
  }

  @Bean
  Converter dateConverter() {
    return new DateConverter();
  }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.