Anil's Blog is Best Viewed on GOOGLE CHROME

Tuesday, June 8, 2010

Add/Minus 1 date from a given date

We will use the Calendar class to achieve.

Controller - Process Request

import java.util.Calendar;

//Here we are getting the projectEnd_Date from PL/SQL which is project end date +1. So we are doing minus from projectEnd_Date variable.

projectEnd_Date  = cstmt.getDate(4);

//Subtracting 1 date from a Given date with the help of Calender CLASS

Calendar cal = Calendar.getInstance();
cal.add(Calendar.DATE, -1);

//We need to change the date to String as we have to set this on MessageStyled Bean.
String pNewEndDate  = pageContext.getOANLSServices().dateToString(cal.getTime());

//And finally we are setting this date on MessageStyledText Bean.
OAMessageStyledTextBean projEndDate = (OAMessageStyledTextBean)pageBean.findChildRecursive("ProjectED");

if(projEndDate != null)
   Debug.log(pageContext,"SCOCreate","String Project End Date is "+pNewEndDate,1);
   projEndDate.setText(pageContext, pNewEndDate); 

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.