Technology Blogs by Members
Explore a vibrant mix of technical expertise, industry insights, and tech buzz in member blogs covering SAP products, technology, and events. Get in the mix!
cancel
Showing results for 
Search instead for 
Did you mean: 
GauravKant
Contributor

In this blog, i will outline how to use UDF as date formatter and how to convert it to different time zone. Here, i have taken a requirement from scn and implemented the same.

Here, in the below code we are getting date as String and converting it to date type. And DateFormat class is used to convert incoming date to required date format and required time zone as well by using set and get timezone.

UDF Code:

try{

String D=var1;

DateFormat converter = new SimpleDateFormat("dd-MM-yyyy");

Date dt=(Date)converter.parse(D);

DateFormat converter1 = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ:00");

converter1.setTimeZone(TimeZone.getTimeZone("PST"));

D=converter1.format(dt);

return D;

}

catch(ParseException e)

{

e.printStackTrace();

}

return null;

UDF Screenshot:

Mapping:

In the above code we have used a date format and timezone. you can use different time zone and format as per your requirement.

Thanks!!

1 Comment
Labels in this area