Skip to Content

Mapping Requirement-Java UDF Date Validation

Dear All,

Kindly help me on below.

Requirement: We a have Source field "ValidatyDate" and need to check IF ValidityDate <= ( Systemdate - 365 days) then YES else NO.

Regards,

Manikandan Shanmugam

Add comment
10|10000 characters needed characters exceeded

  • Follow
  • Get RSS Feed

2 Answers

  • Best Answer
    Sep 26, 2012 at 11:41 AM

    Hi,

    if you want to substract date you just need google for that:

    http://www.rgagnon.com/javadetails/java-0101.html

    then you can do the compare yourself,

    Regards,

    Michal Krawczyk

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Sep 26, 2012 at 01:07 PM

    Hi Manikandan

    Please try the below code, I think it will solve your issue.

    public static long daysBetween(Calendar ValidityDate)
    {
    Calendar systemDate = Calendar.getInstance();

    SimpleDateFormat formatter=
    new SimpleDateFormat("yyyy/MMM/dd");

    Calendar date = (Calendar) startDate.clone();
    long daysBetween = 0;
    while (date.before(systemDate))
    {
    date.add(Calendar.DAY_OF_MONTH, 1);
    daysBetween++;
    }

    If (daysBetween<=365)
    return YES;
    else return NO;
    }

    Best Regards,

    Sagarika

    Add comment
    10|10000 characters needed characters exceeded