on 01-16-2013 7:33 AM
Hi,
I have a incoming date 2011/12/21/10:00:00 this comes in a segment with 1:1 occurance. I need to use this field and increment date by one day in a target field with unbound occurance.
Say if the target node occurs three times. I should populate 2011/12/22/10:00:00 2011/12/23/10:00:00 2011/12/24/10:00:00 respectively.
How do we store a initial segment value and increment it?
Hello,
is it a graphical mapping? if yes you could simply build a function on your own!
Regards,
Thomas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
then go to the ESR and select your software-componenten, then go to the mapping and to tab functions. There you can add a function an fill in the source code on the right side. Just add a variable:
Type: Argument
Name: Input
Java-Type: String
Now u can fill in the source code.
At the end you go to the mapping itself and choose at the very bottom "Functions: User-Defined" and you should find your function.
Regards
Hi prabhas,
In function, make argument as string .Use the code below to increment the date value by one and return the value . Make sure you import the java.text.* .
DateFormat formatter = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Date date = new Date () ;
try
{
date = ( Date )formatter.parse(var1);
}
catch ( ParseException e){}
Calendar clndr = Calendar.getInstance();
clndr.setTime(date);
clndr.add(clndr.DATE, 1);
date = clndr.getTime();
String strDate = formatter.format(date);
return strDate;
Use this code . to increment date .
thanks and regards,
Anup Banerjee
hi Anup,
Thanks it is working but is incrementing the date for first time and assigning the same value for other segments too.
My input structure is
<date> 1:1
<Records>1:unbound
How many times the records segment occur those many times we need to increase the date. the current code you gave is applying the same start date to all occurences of record.
Date value is 2001/11/11-12:00:00 If i got 3 occurance of Records segment then the code should populate. 2001/11/12-12:00:00
2001/11/13-12:00:00
2001/11/14-12:00:00
Currently i am getting 2001/11/12-12:00:00
2001/11/12-12:00:00
2001/11/12-12:00:00
You can combine your source field with a UseOneAsMany to get the the number of records you need. Use the Records node in the context of the root node. Then change your UDF to take all values of the queue. Then adapt your UDF, to something like this::
DateFormat formatter = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
Date date = new Date () ;
//get the date
try
{
date = ( Date )formatter.parse(var1[0]);
}
catch ( ParseException e){}
//for every record, add 1...n to the first date and add it to the result queue
for(int i = 0; i < var1.length; i++)
{
Calendar clndr = Calendar.getInstance();
clndr.setTime(date);
clndr.add(clndr.DATE, i);
date = clndr.getTime();
String strDate = formatter.format(date);
result.addValue(strDate);
}
User | Count |
---|---|
87 | |
10 | |
10 | |
10 | |
7 | |
6 | |
6 | |
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.