1. Get rid of all advertisements and get unlimited access to documents by upgrading to Premium Membership. Upgrade to Premium Now and also get a Premium Badge!

Add/Minus 1 date from a given date

Discussion in 'Site Announcements and Feedback' started by raj, Feb 14, 2013.

  1. raj

    raj Active Member

    Messages:
    4
    Likes Received:
    2
    Trophy Points:
    85
    Add/Minus 1 date from a given date
    We will use the Calendar class to achieve.


    Controller - Process Request

    view plainprint?
    1. import java.util.Calendar;
    2.
    3. //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.
    4.
    5. projectEnd_Date = cstmt.getDate(4);
    6.
    7. //Subtracting 1 date from a Given date with the help of Calender CLASS
    8.
    9. Calendar cal = Calendar.getInstance();
    10. cal.setTime(projectEnd_Date);
    11. cal.add(Calendar.DATE, -1);
    12.
    13. //We need to change the date to String as we have to set this on MessageStyled Bean.
    14. String pNewEndDate = pageContext.getOANLSServices().dateToString(cal.getTime());
    15.
    16. //And finally we are setting this date on MessageStyledText Bean.
    17. OAMessageStyledTextBean projEndDate = (OAMessageStyledTextBean)pageBean.findChildRecursive("ProjectED");
    18.
    19. if(projEndDate != null)
    20. {
    21. Debug.log(pageContext,"SCOCreate","String Project End Date is "+pNewEndDate,1);
    22. projEndDate.setText(pageContext, pNewEndDate);
    23. }