on 05-22-2009 8:32 AM
Hi All,
In my message mapping i have a field CPESPD (effective date) , and in my output i want this date(CPESPD) minus 1 day .
for eg : if CPESPD is 20090521 , then output should be 20090520,
so i wrote a UDF for this :
import java.util.Date;
import java.text.SimpleDateFormat;java.text.ParsePosition;
SimpleDateFormat sdf = new SimpleDateFormat("yyyymmdd");
Date date = sdf.parse(a[0],new ParsePosition(0));
Calendar cal = Calendar.getInstance();
cal.setTime(date);
cal.add(Calendar.DATE, -1);
date = cal.getTime();
String output = sdf.format(date);
result.addValue(output);
this UDF is working fine , but in cases where date is 20090201 , ideally out put should be 20090131
but this UDf gives output as 20080131 , it changes the year also along with day , but doesnt change the month.
Can anybody correct the UDf that i have written ?
Regards ,
Loveena.
Hi rajesh ,
I tried using Gregorian Calendar instaed of calendar , but still it doesnt work
Regards,
Loveena.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks rajesh ,
That solved my problem!!!!!!!!!!!!
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
try using
cal.add(Calendar.DAY_OF_MONTH,-1);
if the above variable is not there then use GregorainCalendar instead of calendar
Rajesh
Edited by: Rajesh on May 22, 2009 1:13 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
83 | |
23 | |
11 | |
9 | |
8 | |
5 | |
5 | |
5 | |
5 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.