public String TO_DATE(Timestamp time,boolean dayOnly){
  if (time == null) {
    if (dayOnly)     return "current_date()";
    return "current_date()";
  }
  StringBuffer dateString=new StringBuffer("TO_DATE('");
  String myDate=time.toString();
  if (dayOnly) {
    dateString.append(myDate.substring(0,10));
    dateString.append("','YYYY-MM-DD')");
  }
 else {
    dateString.append(myDate.substring(0,myDate.indexOf('.')));
    dateString.append("','YYYY-MM-DD HH24:MI:SS')");
  }
  return dateString.toString();
}

public String TO_DATE ( Timestamp time , boolean dayOnly ) { if ( time == null ) { if ( dayOnly ) return "current_date()" ; return "current_date()" ; } StringBuffer dateString = new StringBuffer ( "TO_DATE('" ) ; String myDate = time . toString ( ) ; if ( dayOnly ) { dateString . append ( myDate . substring ( 0 , 10 ) ) ; dateString . append ( "','YYYY-MM-DD')" ) ; } else { dateString . append ( myDate . substring ( 0 , myDate . indexOf ( '.' ) ) ) ; dateString . append ( "','YYYY-MM-DD HH24:MI:SS')" ) ; } return dateString . toString ( ) ; }
create sql to date string from timestamp
