import oracle.jbo.domain.Date;
import java.text.DateFormat;
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.math.RoundingMode;
import java.text.DecimalFormat;
import oracle.apps.fnd.common.VersionInfo;
import oracle.apps.fnd.framework.OAApplicationModule;
import oracle.apps.fnd.framework.OAException;
import oracle.apps.fnd.framework.OAViewObject;
import oracle.apps.fnd.framework.webui.OAControllerImpl;
import oracle.apps.fnd.framework.webui.OAPageContext;
import oracle.apps.fnd.framework.webui.OAWebBeanConstants;
import oracle.apps.fnd.framework.webui.beans.OAWebBean;
import oracle.apps.fnd.framework.webui.beans.message.OAMessageAttachmentLinkBean;
import oracle.apps.fnd.framework.webui.beans.message.OAMessageStyledTextBean;
import oracle.apps.fnd.framework.webui.beans.message.OAMessageTextInputBean;
if("endDateUpdtd".equals(pageContext.getParameter(EVENT_PARAM)))
{
System.out.println("endDateUpdtd fireAction Event Called");
String sdate=pageContext.getParameter("entryStartDt");
String edate=pageContext.getParameter("entryEndDt");
System.out.println("String sdate :-" + sdate);
System.out.println("String edate :-" + edate);
DateFormat formatter;
DateFormat formatter2;
java.util.Date date; //commented on 12 May20
java.util.Date date2;//commented on 12 May20
if (sdate != null && edate != null) {
try {
formatter = new SimpleDateFormat("dd-MMM-yyyy");
date = formatter.parse(sdate);//commented on 12 May20
date2 = formatter.parse(edate);//commented on 12 May20
DateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy");
java.sql.Date sqlStartDateSd = new java.sql.Date (dateFormat.parse(sdate).getTime());
java.sql.Date sqlEndDateEd = new java.sql.Date (dateFormat.parse(edate).getTime());
Date jboDomainStartDate = new Date(sqlStartDateSd);
Date jboDomainEndDate = new Date(sqlEndDateEd);
if(date.after(date2)) {
System.out.println("Start Date is Greater than End Date");
throw new OAException("Start Date is Greater than End Date",OAException.ERROR);
}
if (date2.after(date))
{
System.out.println("End Date is Greater than Start Date");
long noOfDays =((date2.getTime()-date.getTime() )/(1000*60*60*24));
long noOfyrs =(noOfDays/(365));
java.sql.Date sqlStartDate = new java.sql.Date(date.getTime());
java.sql.Date sqlEndDate = new java.sql.Date(date2.getTime());
long noOfyrsJsql =((sqlEndDate.getTime()-sqlStartDate.getTime() )/(1000*60*60*24*365));
System.out.println("String noOfyrsJsql :-" + noOfyrsJsql+ "");
String StrngnoOfDays=String.valueOf(noOfDays);
String StrngnoOfyrs=String.valueOf(noOfyrs);
OAMessageTextInputBean DurationTextBean = (OAMessageTextInputBean)webBean.findChildRecursive("duration");
double dblDiffDays = ((jboDomainEndDate.getValue().getTime() - jboDomainStartDate.getValue().getTime()) / (1000 * 60 * 60 * 24));
double dblNoOfyrs =(dblDiffDays/(365));
DecimalFormat df = new DecimalFormat("#.##");
double dblNoOfyrsFnl = Double.parseDouble(dblNoOfyrs+ ""); //df.format((double)dblNoOfyrs);
String dblNoOfyrsFnlStg =df.format(dblNoOfyrsFnl);
DurationTextBean.setValue(pageContext, dblNoOfyrsFnlStg+" Year(s)");
}
java.sql.Date sqlDate = new java.sql.Date(date.getTime());
oracle.jbo.domain.Date jboDate =
new oracle.jbo.domain.Date(sqlDate);
System.out.println("jboDate"+jboDate+"sqlDate"+sqlDate);
} catch (ParseException e) {
e.printStackTrace();
}
}
}
This is very useful post,Thanks Pavan
ReplyDelete