Comparision of Dates in Controller
1)
Date StartDate= (Date)CurrentRow.getAttribute("StartDate");
Date CurrentDate = (Date)am.getOADBTransaction().getCurrentDBDate();
java.sql.Date sdate = (java.sql.Date) StartDate.dateValue();
java.sql.Date cdate = (java.sql.Date) CurrentDate.dateValue();
int days = daysBetween(sdate,cdate );
public int daysBetween(java.sql.Date d1, java.sql.Date d2){
return (int)( (d2.getTime() - d1.getTime()) / (1000 * 60 * 60 * 24));
}
2)
OAViewObject oaviewobject1 = (OAViewObject)am.findViewObject("NewEmployeeVO1");
System.out.println("1");
if (oaviewobject1 != null)
{
System.out.println("Inside");
oaviewobject1.reset(); //New line added
oaviewobject1.next(); //new line added
OARow row = (OARow)oaviewobject1.getCurrentRow();
Date sDate =(Date)row.getAttribute("EffectiveStartDate");
Date eDate =(Date)row.getAttribute("EffectiveEndDate");
java.util.Date VChangeDateTime =
new java.util.Date(sDate.timestampValue().getTime());
if (sDate !=null && eDate !=null)
{
long m1 = sDate.timestampValue().getTime() ;
long m2 = eDate.timestampValue().getTime();
long diff = m2 - m1;
int diffDays = Math.round(diff / (24 * 60 * 60 * 1000));
if (diffDays >365)
{
System.out.println("Date is greater than 365");
}
else
{
System.out.println("Date is less than 365");
}
No comments:
Post a Comment