Examples of CalendarConverter


Examples of org.apache.wicket.util.convert.converter.CalendarConverter

  /**
   * Test calendar locale conversions.
   */
  public void testCalendarConverter()
  {
    CalendarConverter converter = new CalendarConverter();

    Calendar cal = Calendar.getInstance(DUTCH_LOCALE);
    cal.clear();
    cal.set(2011, Calendar.MAY, 1);

    assertEquals("1-5-11", converter.convertToString(cal, DUTCH_LOCALE));
    assertEquals(cal, converter.convertToObject("1-5-11", DUTCH_LOCALE));

    cal = Calendar.getInstance(Locale.US);
    cal.clear();
    cal.set(2011, Calendar.MAY, 1);
    assertEquals("5/1/11", converter.convertToString(cal, Locale.US));
    assertEquals(cal, converter.convertToObject("5/1/11", Locale.US));

    try
    {
      converter.convertToObject("whatever", Locale.US);
      fail("Conversion should have thrown an exception");
    }
    catch (ConversionException e)
    {
      // this is correct
    }
    try
    {
      converter.convertToObject("5/1/11whatever", Locale.US);
      fail("Conversion should have thrown an exception");
    }
    catch (ConversionException e)
    {
      // this is correct
View Full Code Here

Examples of org.apache.wicket.util.convert.converter.CalendarConverter

    set(Long.TYPE, LongConverter.INSTANCE);
    set(Long.class, LongConverter.INSTANCE);
    set(Short.TYPE, ShortConverter.INSTANCE);
    set(Short.class, ShortConverter.INSTANCE);
    set(Date.class, new DateConverter());
    set(Calendar.class, new CalendarConverter());
    set(java.sql.Date.class, new SqlDateConverter());
    set(java.sql.Time.class, new SqlTimeConverter());
    set(java.sql.Timestamp.class, new SqlTimestampConverter());
    set(BigDecimal.class, new BigDecimalConverter());
  }
View Full Code Here

Examples of org.apache.wicket.util.convert.converter.CalendarConverter

  /**
   * Test calendar locale conversions.
   */
  public void testCalendarConverter()
  {
    CalendarConverter converter = new CalendarConverter();

    Calendar cal = Calendar.getInstance(DUTCH_LOCALE);
    cal.clear();
    cal.set(2011, Calendar.MAY, 1);

    assertEquals("1-5-11", converter.convertToString(cal, DUTCH_LOCALE));
    assertEquals(cal, converter.convertToObject("1-5-11", DUTCH_LOCALE));

    cal = Calendar.getInstance(Locale.US);
    cal.clear();
    cal.set(2011, Calendar.MAY, 1);
    assertEquals("5/1/11", converter.convertToString(cal, Locale.US));
    assertEquals(cal, converter.convertToObject("5/1/11", Locale.US));

    try
    {
      converter.convertToObject("whatever", Locale.US);
      fail("Conversion should have thrown an exception");
    }
    catch (ConversionException e)
    {
      // this is correct
    }
    try
    {
      converter.convertToObject("5/1/11whatever", Locale.US);
      fail("Conversion should have thrown an exception");
    }
    catch (ConversionException e)
    {
      // this is correct
View Full Code Here

Examples of org.apache.wicket.util.convert.converter.CalendarConverter

    set(BigDecimal.class, new BigDecimalConverter());
    set(Date.class, new DateConverter());
    set(java.sql.Date.class, new SqlDateConverter());
    set(java.sql.Time.class, new SqlTimeConverter());
    set(java.sql.Timestamp.class, new SqlTimestampConverter());
    set(Calendar.class, new CalendarConverter());
  }
View Full Code Here

Examples of org.apache.wicket.util.convert.converter.CalendarConverter

    set(Long.TYPE, LongConverter.INSTANCE);
    set(Long.class, LongConverter.INSTANCE);
    set(Short.TYPE, ShortConverter.INSTANCE);
    set(Short.class, ShortConverter.INSTANCE);
    set(Date.class, new DateConverter());
    set(Calendar.class, new CalendarConverter());
    set(java.sql.Date.class, new SqlDateConverter());
    set(java.sql.Time.class, new SqlTimeConverter());
    set(java.sql.Timestamp.class, new SqlTimestampConverter());
    set(BigDecimal.class, new BigDecimalConverter());
  }
View Full Code Here

Examples of org.apache.wicket.util.convert.converter.CalendarConverter

    set(BigDecimal.class, new BigDecimalConverter());
    set(Date.class, new DateConverter());
    set(java.sql.Date.class, new SqlDateConverter());
    set(java.sql.Time.class, new SqlTimeConverter());
    set(java.sql.Timestamp.class, new SqlTimestampConverter());
    set(Calendar.class, new CalendarConverter());
  }
View Full Code Here

Examples of org.apache.wicket.util.convert.converter.CalendarConverter

   * Test calendar locale conversions.
   */
  @Test
  public void calendarConverter()
  {
    CalendarConverter converter = new CalendarConverter();

    Calendar cal = Calendar.getInstance(DUTCH_LOCALE);
    cal.clear();
    cal.set(2011, Calendar.MAY, 1);

    assertEquals("1-5-11", converter.convertToString(cal, DUTCH_LOCALE));
    assertEquals(cal, converter.convertToObject("1-5-11", DUTCH_LOCALE));

    cal = Calendar.getInstance(Locale.US);
    cal.clear();
    cal.set(2011, Calendar.MAY, 1);
    assertEquals("5/1/11", converter.convertToString(cal, Locale.US));
    assertEquals(cal, converter.convertToObject("5/1/11", Locale.US));

    try
    {
      converter.convertToObject("whatever", Locale.US);
      fail("Conversion should have thrown an exception");
    }
    catch (ConversionException e)
    {
      // this is correct
    }
    try
    {
      converter.convertToObject("5/1/11whatever", Locale.US);
      fail("Conversion should have thrown an exception");
    }
    catch (ConversionException e)
    {
      // this is correct
View Full Code Here

Examples of org.apache.wicket.util.convert.converter.CalendarConverter

    input.clear();
    input.set(2011, Calendar.MAY, 7);

    StyleDateConverter styleDateConverter = new StyleDateConverter("F-", false);

    CalendarConverter calendarConverter = new CalendarConverter(styleDateConverter);

    String expected = styleDateConverter.convertToString(input.getTime(), locale);
    String actual = calendarConverter.convertToString(input, locale);

    Assert.assertEquals(expected, actual);

    Calendar revert = calendarConverter.convertToObject(actual, locale);

    Assert.assertEquals(input, revert);
  }
View Full Code Here

Examples of org.apache.wicket.util.convert.converter.CalendarConverter

    set(Long.TYPE, LongConverter.INSTANCE);
    set(Long.class, LongConverter.INSTANCE);
    set(Short.TYPE, ShortConverter.INSTANCE);
    set(Short.class, ShortConverter.INSTANCE);
    set(Date.class, new DateConverter());
    set(Calendar.class, new CalendarConverter());
    set(java.sql.Date.class, new SqlDateConverter());
    set(java.sql.Time.class, new SqlTimeConverter());
    set(java.sql.Timestamp.class, new SqlTimestampConverter());
    set(BigDecimal.class, new BigDecimalConverter());
  }
View Full Code Here

Examples of org.dozer.converters.CalendarConverter

   */
  @Test
  public void testAccessors() throws Exception {
    DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.LONG);

    CalendarConverter cc = new CalendarConverter(dateFormat);
    assertEquals(dateFormat, cc.getDateFormat());

    StringConverter sc = new StringConverter(null);
    DateFormatContainer dfc = new DateFormatContainer(null);
    sc.setDateFormatContainer(dfc);
    assertEquals(dfc, sc.getDateFormatContainer());
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.