cancel
Showing results for 
Search instead for 
Did you mean: 

Date function

Former Member
0 Kudos

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

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

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.

Answers (4)

Answers (4)

santhosh_kumarv
Active Contributor
0 Kudos

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

Former Member
0 Kudos

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>

Former Member
0 Kudos

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

Former Member
0 Kudos

>>IS it possible to create a mapping where you enter a date + one day?

yes, it's possibel.

Regards

justin_santhanam
Active Contributor
0 Kudos

Vijaya,

Its not possible thru standard function. You have to write UDF in order to achieve the same. If its possible could you tell us how?

Best regards,

raj.

Former Member
0 Kudos

Hi Raj,

I agree with you Raj, if the input field type is a Date filed, we can't play with it. If it is string field, where you can add some number to the date, we can. I assumed, he is referring to string field. I am sorry, if my assumption is wrong.

Regards

Former Member
0 Kudos

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