コード例 #1
0
 @Test
 public void testCalendar2SqlDate() {
   Calendar calendar = Calendar.getInstance();
   calendar.setTimeInMillis(time);
   Date date = sqlDateConverter.convert(calendar);
   assertEquals(time, date.getTime());
 }
コード例 #2
0
  @Test
  public void testConversion() {
    assertNull(sqlDateConverter.convert(null));

    assertEquals(Date.valueOf("2011-01-01"), sqlDateConverter.convert(Date.valueOf("2011-01-01")));
    assertEquals(new Date(1111111), sqlDateConverter.convert(Integer.valueOf(1111111)));
    assertEquals(Date.valueOf("2011-01-01"), sqlDateConverter.convert("2011-01-01"));
    assertEquals(Date.valueOf("2011-01-01"), sqlDateConverter.convert("      2011-01-01       "));

    try {
      sqlDateConverter.convert("2011.01.01");
      fail();
    } catch (TypeConversionException ignore) {
    }

    try {
      sqlDateConverter.convert("a");
      fail();
    } catch (TypeConversionException ignore) {
    }
  }
コード例 #3
0
 @Test
 public void testJDateTime2SqlDate() {
   JDateTime jdt = new JDateTime(time);
   Date date = sqlDateConverter.convert(jdt);
   assertEquals(time, date.getTime());
 }
コード例 #4
0
 @Test
 public void testSqlTime2SqlDate() {
   Time sqltime = new Time(time);
   Date date = sqlDateConverter.convert(sqltime);
   assertEquals(time, date.getTime());
 }
コード例 #5
0
 @Test
 public void testSqlDate2SqlDate() {
   Date date2 = new Date(time);
   Date date = sqlDateConverter.convert(date2);
   assertEquals(time, date.getTime());
 }
コード例 #6
0
 @Test
 public void testTimestamp2SqlDate() {
   Timestamp timestamp = new Timestamp(time);
   Date date = sqlDateConverter.convert(timestamp);
   assertEquals(time, date.getTime());
 }
コード例 #7
0
 @Test
 public void testNull() {
   assertNull(sqlDateConverter.convert(null));
 }