on 07-20-2007 2:38 PM
Hello Gurus,
Is it possible to create a mapping where you enter a date + one day?
I have a date and need to add one day to it as a delivery date. Is this possible with standaard mapping functions?
Message was edited by:
G. Koopmann
Hi G. Koopmann !
I think you need a simple udf like this:
where "a" is the input parameter that should match the date format of the dateFormat object.
imports: java.util.Calendar;java.text.SimpleDateFormat;java.text.DateFormat;
public String addOneDay(String a,Container container){
String notifyDates = a;
Calendar calendar = Calendar.getInstance ( ) ;
DateFormat dateFormat = new SimpleDateFormat ( "yyyy-MM-dd" ) ;
try {
Date date = dateFormat.parse ( notifyDates ) ;
calendar.setTime ( date ) ;
calendar.add ( Calendar.DATE, 1 ) ;
return dateFormat.format ( calendar.getTime ( ) ) ;
} catch ( Exception e ) {
return "error";
}
}
Regards,
Matias.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
U can achieve this trough thie UDF.
Try this UDF.
public String rearrangedate(String a,Container container)
{
String date,month,year;
String result;
year=a.substring(0,4);
month=a.substring(4,6);
date=integer.parseInt(a.substring(6,8));
date=date+1;
result= datemonthyear ;
return result;
}
This UDF accepts the input in the YYYYDDMM format and also changes it into DDMMYY format adding a 1 day to the date.
Try this out
Regards
Santhosh
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I made a mistake if you work with month and year you have to complicate a little the mapping:
<a href="http://img510.imageshack.us/img510/944/screenhunter149mv6.png">http://img510.imageshack.us/img510/944/screenhunter149mv6.png</a>
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
As I know there are not any function to do that directly. Anyway you can do that by doing a substring of the day an add one to this day. After that you can paste it with the month and the year. You have to pay attention to the 12 last days of each month that you can map directly with a <b>FixValues</b>. You have to use the same <b>FixValues</b> but mapping the 12 last day to a boolean value.
I link you the mapping schema:
<a href="http://img110.imageshack.us/img110/7666/screenhunter147mq2.png">http://img110.imageshack.us/img110/7666/screenhunter147mq2.png</a>
Otherwise you can do the same by a java user defined function.
Hope it helps you
Regards
Gonzalo
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
>>IS it possible to create a mapping where you enter a date + one day?
yes, it's possibel.
Regards
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Within a string it is still not possible then. Otherwise you need to create several IF then Else statements for the determination if the ending of a month is reached, so that is not a good solution. Ok, now I know for shure that is not possible, now I need to find a Java function for that...
Thnx
User | Count |
---|---|
90 | |
10 | |
10 | |
10 | |
7 | |
7 | |
6 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.