Quantcast
Channel: pacesettergraam
Viewing all articles
Browse latest Browse all 314

Date Comparison in OAF using Java

$
0
0

Requirement: To compare the Start Date and End Date in the OAF Page and validate if Start date is greater than the End Date.

Below code will be doing the validation

 String stDate   = null;   
Date   strtDate = null;
        Date   edDate   = null;
        String endDate  = null;
        try 
        {
            stDate = (poolCarVO.getCurrentRow().getAttribute("StartDate").toString());
            SimpleDateFormat         dateFormat       = new SimpleDateFormat("yyyy-MM-dd");
            endDate =  poolCarVO.getCurrentRow().getAttribute("EndDate").toString();
            strtDate = (Date)new Date(dateFormat.parse(stDate).getTime()+1);
            edDate = (Date)new Date(dateFormat.parse(endDate).getTime()+1);
            System.out.println("Inside ReqCreationCO startDate  --> "   + strtDate+" endDate "+edDate);
         }
         catch (Exception e)
         {
             System.out.println("startDate Exc  --> "   +   e);
             pageContext.writeDiagnostics(this , "startDate Exc  --> "   +   e , 4);
         }
        if(strtDate.after(edDate))
        {
            System.out.println("Inside ReqCreationCO startDate  --> "   + strtDate+" endDate "+edDate);
            throw new OAException("Start Date Should be Greater Than End Date!",OAException.ERROR);
        }
        else
        {
            System.out.println("Inside ReqCreationCO Checking the Else Logic---- Works fine  --> "   + strtDate+" endDate "+edDate);
            
        }



Viewing all articles
Browse latest Browse all 314

Trending Articles