Thursday, October 3, 2013

Date

DATE  :
OAF :

When we are trying to fetch the Date information and planning to compare two dates ,then below is the process to be performed in OAF (JDEV).

1.Take the fields using current row into a oracle.jbo.domain.date
2.Convert the above domain date into String
3.and Using Simpledateformat ,and parse functions compare the dates (java.util.date)

  IDCardHeaderEOVOImpl headervo = getIDCardHeaderEOVO1();
  IDCardHeaderEOVORowImpl headerrow =(IDCardHeaderEOVORowImpl)headervo.first();
  oracle.jbo.domain.Date Date1 =headerrow.getCntIssueDate();
  oracle.jbo.domain.Date Date2 =headerrow.getCntExpiryDate();
  String datesrt =(String)Date1.toString();
  String dateesrt = (String)Date2.toString();
  SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
  java.util.Date udate1 = null ;
  java.util.Date udate2 = null ;
  try 
 {
 udate1 = sdf.parse(datesrt);
 udate2 = sdf.parse(dateesrt);
 }
catch (Exception e )
{
  e.printStackTrace();
}
if(udate1.compareTo(udate2)>0)
{
throw  new OAException("Expiry date cannot be prior to Issue date.",OAException.ERROR);  
}

No comments:

Post a Comment