Skip to Content
0
Former Member
Dec 20, 2006 at 07:44 PM

Substract 1 day to a date, user-defined function.

17 Views

I want to sybstract 1 day from the given DATE.

My userdefined function has only 1 argument which receives the given Date.

argument name is " a "

Imports :

java.util.Date;java.text.*;java.util.Calendar;java.util.GregorianCalendar;

public String dateTrans(String a,Container container){

String DATE_FORMAT = "yyyyMMdd";

java.text.SimpleDateFormat sdf = new java.text.SimpleDateFormat(DATE_FORMAT);

Calendar c1 = Calendar.getInstance();

c1.set(Calendar.YEAR,2006);

c1.set(Calendar.MONTH,6);

c1.set(Calendar.DATE,7);

c1.add(Calendar.DATE, -1);

String s = sdf.format(c1.getTime());

return s;

}

My target field receiving the value " 20060706 "

which was my defaut date - 1 day.

Its not taking the value which I'm passing as an argument.

can someone please look into it, as I'm not that good at "Java Programming "

Thanks

sagar