/**** String to Sql Date Conversion and passing this sql date object to prepared Statement in oaf ****/
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
OAMessageStyledTextBean lastUpdateDate = (OAMessageStyledTextBean)webBean.findIndexedChildRecursive("LastUpdate");
java.util.Date utilDate = (Date)lastUpdateDate.getValue(pageContext);
System.out.println("Last Update Date is..1--->"+utilDate);
java.sql.Date sqlDate = null;
try
{
DateFormat formatter ;
formatter = new SimpleDateFormat("dd-MMM-yyyy");
String formatDate = formatter.format(utilDate);
System.out.println("formatDate--->"+formatDate);
sqlDate = java.sql.Date.valueOf(new String(formatDate));
System.out.println("sql Date---->"+sqlDate);
}
catch(Exception e)
{
System.out.println("Exception :"+e);
}
try
{
String Query = "UPDATE XXBT_AMS_TC_DETAILS SET REASON = ? , DATE_CREATED = ? WHERE TICKET_NUMBER = ? ";
PreparedStatement stmt = conn.prepareStatement(Query);
stmt.setString(1,recentUpdate);
// stmt.setDate(2,oadbtransactionimpl.getCurrentDBDate().dateValue());which takes the current db date
stmt.setDate(2,sqlDate); // which takes the user input date
System.out.println("Date Created---"+oadbtransactionimpl.getCurrentDBDate().dateValue());
stmt.setString(3,incidentNumber2);
stmt.executeUpdate();
conn.commit();
import java.text.DateFormat;
import java.text.SimpleDateFormat;
import java.util.Date;
OAMessageStyledTextBean lastUpdateDate = (OAMessageStyledTextBean)webBean.findIndexedChildRecursive("LastUpdate");
java.util.Date utilDate = (Date)lastUpdateDate.getValue(pageContext);
System.out.println("Last Update Date is..1--->"+utilDate);
java.sql.Date sqlDate = null;
try
{
DateFormat formatter ;
formatter = new SimpleDateFormat("dd-MMM-yyyy");
String formatDate = formatter.format(utilDate);
System.out.println("formatDate--->"+formatDate);
sqlDate = java.sql.Date.valueOf(new String(formatDate));
System.out.println("sql Date---->"+sqlDate);
}
catch(Exception e)
{
System.out.println("Exception :"+e);
}
try
{
String Query = "UPDATE XXBT_AMS_TC_DETAILS SET REASON = ? , DATE_CREATED = ? WHERE TICKET_NUMBER = ? ";
PreparedStatement stmt = conn.prepareStatement(Query);
stmt.setString(1,recentUpdate);
// stmt.setDate(2,oadbtransactionimpl.getCurrentDBDate().dateValue());which takes the current db date
stmt.setDate(2,sqlDate); // which takes the user input date
System.out.println("Date Created---"+oadbtransactionimpl.getCurrentDBDate().dateValue());
stmt.setString(3,incidentNumber2);
stmt.executeUpdate();
conn.commit();
No comments:
Post a Comment