Monday 9 October 2017

Date formatting in OAF


Convert the String object to java.sql.Date object using stringToDate() function from oracle.apps.fnd.framework.OANLSServices class like below.

java.sql.Date getClientSysdate(){
OADBTransaction trx = 
(OADBTransaction)getApplicationModule().getTransaction();
OANLSServices nls = trx.getOANLSServices();
oracle.jbo.domain.Date serverDate = trx.getCurrentDBDate();

java.util.Date javaClientDate = nls.getUserDate(serverDate);
long longDate = javaClientDate.getTime();
return new java.sql.Date(longDate);
}


if (gRow.getAttribute("PromisedDate")!=null)
  {
   ReferenceId= gRow.getAttribute("PromisedDate").toString();//.substring(0,19);
      pageContext.writeDiagnostics(this, " Promisedate :"+ReferenceId, 1);
     // Calendar calendar = Calendar.getInstance();
    //SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
      //String today = dateFormat.format(ReferenceId);     
    //pageContext.writeDiagnostics(this, " Promised DATE WITh FORMAT "+today,1);
        if(result==0)
        {
           pageContext.writeDiagnostics(this, "Setting PO date to DFF",1);
   SimpleDateFormat dt = new SimpleDateFormat("yyyy/mm/dd hh:mm:ss"); 
          
       gRow.setAttribute("Attribute1",dt.format(ReferenceId));
        // gRow.setAttribute("Attribute1","2015/02/15 12:01:10");
       gRow.setAttribute("AttributeCategory","28385");
       }

  }

No comments:

Post a Comment