// ===================================================================================
  //                                                                        BindVariable
  //                                                                        ============
  public void test_getBindVariableText_dateFormat_basic() {
    // ## Arrange ##
    Date date = DfTypeUtil.toDate("2009-10-27");

    // ## Act ##
    String actual = createTarget().getBindVariableText(date);

    // ## Assert ##
    assertEquals("'2009-10-27'", actual);
  }
Esempio n. 2
0
 @SuppressWarnings("unchecked")
 public <PROPERTY> PROPERTY analyzeDate(Class<PROPERTY> javaType) {
   final Object obj = getColumnValue();
   if (Time.class.isAssignableFrom(javaType)) {
     return (PROPERTY) DfTypeUtil.toTime(obj);
   } else if (Timestamp.class.isAssignableFrom(javaType)) {
     return (PROPERTY) DfTypeUtil.toTimestamp(obj);
   } else {
     return (PROPERTY) DfTypeUtil.toDate(obj);
   }
 }
  public void test_getBindVariableText_dateFormat_custom() {
    // ## Arrange ##
    String format = "date $df:{yyyy-MM-dd}";
    Date date = DfTypeUtil.toDate("2009-10-27");

    // ## Act ##
    String actual = createTargetWithDateFormat(format).getBindVariableText(date);

    // ## Assert ##
    assertEquals("date '2009-10-27'", actual);
  }
  public void test_buildDisplaySql_date_default_bc_basic() {
    // ## Arrange ##
    String sql = "select * from where FOO_DATE = ?";
    Date fooDate = DfTypeUtil.toDate("BC1010/12/12 12:34:56");

    // ## Act ##
    String actual = createTarget().buildDisplaySql(sql, new Object[] {fooDate});

    // ## Assert ##
    log(actual);
    assertTrue(actual.contains("FOO_DATE = 'BC1010-12-12'"));
  }
  public void test_buildDisplaySql_date_format() {
    // ## Arrange ##
    String sql = "select * from where FOO_DATE = ?";
    Date fooDate = DfTypeUtil.toDate("2010/12/12 12:34:56");

    // ## Act ##
    String actual =
        createTargetWithDateFormat("yyyy@MM@dd").buildDisplaySql(sql, new Object[] {fooDate});

    // ## Assert ##
    log(actual);
    assertTrue(actual.contains("FOO_DATE = '2010@12@12'"));
  }
 protected Date toUtilDate(Date date) {
   return DfTypeUtil.toDate(date); // if sub class, re-create as pure date
 }