Contact : oafqueries@gmail.com (OAF/ADF Trainings and Customizations)

Wednesday, September 15

How to set system date -1 on a View Attribute

 Hi,
 The following code sets the sysdate-1 on a View Attribute.

             int MILLIS_IN_DAY = 1000 * 60 * 60 * 24;
              Date date = new Date();
              oracle.jbo.domain.Date oracleDate = null;
              try
              {
                SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MM-yyyy");
                String prevDate = dateFormat.format(date);

                java.util.Date newdate = dateFormat.parse(prevDate);
                oapagecontext.writeDiagnostics(this,"Today dd-MM-yyyy = " + dateFormat.format(newdate),1);
                long javaMilliseconds = (long)(newdate.getTime()- MILLIS_IN_DAY);

                java.sql.Date javaSqlDate = new java.sql.Date(javaMilliseconds);
                oapagecontext.writeDiagnostics(this,"Java Sql Date is "+ javaSqlDate,1);
                oracleDate = new oracle.jbo.domain.Date(javaSqlDate);
              }
              catch(Exception e)
              {
                e.printStackTrace();
              }
             
              oapagecontext.writeDiagnostics(this,"Oracle Date is "+ oracleDate,1);
              row.setAttribute("DateStart",oracleDate);

Thanks,
Gaurav

No comments:

Post a Comment