question: 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 ( ) ; }
target:  Create SQL TO Date String from Timestamp