cancel
Showing results for 
Search instead for 
Did you mean: 

UDF to increment date

Former Member
0 Kudos

Hi,

I have a incoming date of format YYYY:MM:DD-HH:MM:SS

We need to increment the time by 10 minutes. Can anyone help me with the UDF.

TIA

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Kiran,

YYYY:MM:DD-HH:MM:SS is not standard date format . I assume that format is "yyyy-MM-dd HH:mm:ss".

Very simple to increment minutes  by 10 from UDF .

In function, make argument as string .Use the code below  and return the value .

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.MINUTE, 10);

date = clndr.getTime();

String strDate = formatter.format(date);

return strDate;

This will complete your requirement .

thanks and regards,

Anup Banerjee

Former Member
0 Kudos

Hi

I am getting some errors at runtime

Function calculate, Line 1:

cannot find symbol symbol  : class DateFormat location: class com.sap.xi.tf._MM_********** DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); ^

Function calculate, Line 1:

cannot find symbol symbol  : class SimpleDateFormat location: class com.sap.xi.tf._MM_********** DateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");

                            ^

Function calculate, Line 13:

cannot find symbol symbol  : class ParseException location: class com.sap.xi.tf._MM_********** catch ( ParseException  e){}         ^ Note: /usr/sap/XPI/DVEBMGS00/j2ee/cluster/server0/./temp/classpath_resolver/Map497c143f5f1311e29edb000000127d02/source/com/sap/xi/tf/_MM_**********.java uses or overrides a deprecated API. Note: Recompile with -Xlint:deprecation for details. 3 errors

Former Member
0 Kudos

Hi Kiran,

you have not import the java.text.* that is why you are getting the error .

Just import  java.text.* in import instructions tab . will solve the error .

thanks and regards,

Anup Banerjee

Former Member
0 Kudos

Anup,

Thanks mate its working. But its incrementing the system time by 10 minutes. Not the given input. How do we modify it?

Former Member
0 Kudos

I think your input value (var1) is incorrect . that is why it is not parsing the value .

try with    2013-01-15 07:32:35   value  and follow the pattern .

thanks and regards,

Anup Banerjee

Former Member
0 Kudos

Thanks and Rewarded

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

Use the below logic.Fine tune it as per your req.

import java.util.Calendar;

Date Inputtime

Calendar calendar = Calendar.getInstance();
   calendar
.setTime(Inputtime);
   calendar
.add(Calendar.MINUTE, 10);
   Inputtime
= calendar.getTime();


Regrads

Venkat