'2009/09'에 해당되는 글 1건

  1. 2009.09.18 기간검색할때 쓰세요
시작일, 종료일 yyyy-MM-dd 형식으로 입력받아서 검색할때 그대~로 쓰시면 됩니다.
if( UtilBean.isValidDate(formattype, startdate) || UtilBean.isValidDate(formattype, enddate) ) {
          /*등록일 검색*/
         
          SimpleDateFormat sdf = new SimpleDateFormat(formattype);
          boolean isDuration = ( UtilBean.isValidDate(formattype, startdate) && UtilBean.isValidDate(enddate, formattype) );
          bWhere.append(" and ");
          if( isDuration ){
          bWhere.append(" ( ");
          }
          if( UtilBean.isValidDate(formattype, startdate) ){
            bWhere.append("A.CREATEDON >= to_date('").append(startdate).append("', '").append( formattype.toUpperCase() ).append("') ");
          }
          if( isDuration ){
            bWhere.append(" and ");
          }
          if( UtilBean.isValidDate(formattype, enddate) ){
            bWhere.append("A.CREATEDON < to_date('").append( sdf.format(new java.util.Date( sdf.parse(enddate).getTime()+( 1000 * 24 * 3600 ))) ).append("', '").append( formattype.toUpperCase() ).append("') ");
          }
          if( isDuration ){
          bWhere.append(" ) ");
          }
        }

String sWhere = bWhere.toString().replaceFirst("(?i)and", "");

/* 이건 catch 말고 답없음. */
  public static boolean isValidDate( SimpleDateFormat sdf, String date ) {
    try{
      sdf.parse(date);
    }catch(ParseException e){
      return false;
    }
    return true;
  }



Posted by 윤재현 :