<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>Question Re: Date and Time format in UTC java UDF in Technology Q&amp;A</title>
    <link>https://community.sap.com/t5/technology-q-a/date-and-time-format-in-utc-java-udf/qaa-p/8027210#M2864862</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Amitsri , thanks but this looks normal concating z to the existing one .....I have to add +4 hours to existing time ..that means iam converting input to UTC format...thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Thu, 14 Jul 2011 06:33:16 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2011-07-14T06:33:16Z</dc:date>
    <item>
      <title>Date and Time format in UTC java UDF</title>
      <link>https://community.sap.com/t5/technology-q-a/date-and-time-format-in-utc-java-udf/qaq-p/8027204</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi All,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have an input date time  iIhave to convert this to UTC for example &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;if its 1994-11-05T08:15:30-05:00  it has to be converted to 1994-11-05T13:15:30Z &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Jul 2011 06:06:09 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/date-and-time-format-in-utc-java-udf/qaq-p/8027204</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-14T06:06:09Z</dc:date>
    </item>
    <item>
      <title>Re: Date and Time format in UTC java UDF</title>
      <link>https://community.sap.com/t5/technology-q-a/date-and-time-format-in-utc-java-udf/qaa-p/8027205#M2864857</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kiran ,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You can use Java UDF to covert the timeZone&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;// Suppose this is a date and time in the EST timezone   
String value = "2006-11-28 09:45:12";   
    
DateFormat df1 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");   
df1.setTimeZone(TimeZone.getTimeZone("EST"));   
    
// Parses the value and assumes it represents a date and time in the EST timezone   
Date d = df1.parse(value);   
    
DateFormat df2 = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");   
df2.setTimeZone(TimeZone.getTimeZone("CET"));   
    
// Formats the date in the CET timezone   
System.out.println(df2.format(d));&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;   &lt;/P&gt;&lt;P&gt;    &lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

public static String convertLocalTimeToUTC(String p_city, String p_localDateTime) throws Exception{   
  
String lv_dateFormateInUTC="";//Will hold the final converted date   
Datelv_localDate = null;   
Stringlv_localTimeZone ="";   
SimpleDateFormat lv_formatter;   
SimpleDateFormat lv_parser;   
    
//Temp for testing(mapping of cities and timezones will eventually be in a properties file   
if(p_city.equals("LON")){   
lv_localTimeZone="Europe/London";   
}else if(p_city.equals("NBI")){   
lv_localTimeZone="EAT";   
}else if(p_city.equals("BRS")){   
lv_localTimeZone="Europe/Brussels";   
}else if(p_city.equals("MNT")){   
lv_localTimeZone="America/Montreal";   
}else if(p_city.equals("LAS")){   
lv_localTimeZone="PST";   
}   
  
//create a new Date object using the timezone of the specified city   
lv_parser = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");   
lv_parser.setTimeZone(TimeZone.getTimeZone(lv_localTimeZone));   
lv_localDate = lv_parser.parse(p_localDateTime);   
  
//Set output format prints "2007/10/25  18:35:07 EDT(-0400)"   
lv_formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss z'('Z')'");   
lv_formatter.setTimeZone(TimeZone.getTimeZone(lv_localTimeZone));   
  
System.out.println("convertLocalTimeToUTC: "+p_city+": "+" The Date in the local time zone " + lv_formatter.format(lv_localDate));   
  
//Convert the date from the local timezone to UTC timezone   
lv_formatter.setTimeZone(TimeZone.getTimeZone("UTC"));   
lv_dateFormateInUTC = lv_formatter.format(lv_localDate);   
System.out.println("convertLocalTimeToUTC: "+p_city+": "+" The Date in the UTC time zone " + lv_dateFormateInUTC);   
  
  
return lv_dateFormateInUTC;   
}   

/**  
 * Test method for {@link com.scratch.datetime.DateTimeUtil#convertUTCtoLocalTime(java.lang.String, java.lang.String)}.  
 */  
public final void testConvertUTCtoLocalTime() {   
try {   
assertEquals("testConvertLocalTimeToUTC:LON ", "03-11-2008 11:00:00 GMT(+0000)" ,DateTimeUtil.convertUTCtoLocalTime("LON", "03-11-2008 11:00:00"));   
assertEquals("testConvertLocalTimeToUTC:NBI ", "03-11-2008 14:00:00 EAT(+0300)" ,DateTimeUtil.convertUTCtoLocalTime("NBI", "03-11-2008 11:00:00"));   
assertEquals("testConvertLocalTimeToUTC:BRS ", "03-11-2008 12:00:00 CET(+0100)" ,DateTimeUtil.convertUTCtoLocalTime("BRS", "03-11-2008 11:00:00"));   
assertEquals("testConvertLocalTimeToUTC:MNT ", "03-11-2008 06:00:00 EST(-0500)" ,DateTimeUtil.convertUTCtoLocalTime("MNT", "03-11-2008 11:00:00"));   
assertEquals("testConvertLocalTimeToUTC:LAS ", "03-11-2008 03:00:00 PST(-0800)" ,DateTimeUtil.convertUTCtoLocalTime("LAS", "03-11-2008 11:00:00"));   
} catch (Exception e) {   
e.printStackTrace();   
fail("convertUTCtoLocalTime: Exception :" + e);    
}   
}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;   &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;public static Calendar getTimeZoneDate(Date userDate,String userTimeZone,String serverTimeZone){   
 Calendar serverCalendar=null;   
 Calendar localCalendar=new GregorianCalendar(TimeZone.getTimeZone(userTimeZone),Locale.US);   
 int DATE=userDate.getDay();   
 int MONTH=userDate.getMonth();   
 int YEAR=1900+userDate.getYear();   
    
 int HOUR_OF_DAY=userDate.getHours();   
 int MINUTE=userDate.getMinutes();   
 //int SECOND=userDate.getMinutes();   
 //localCalendar.set(YEAR,MONTH,DATE,HOUR_OF_DAY,MINUTE,SECOND);   
 localCalendar.set(Calendar.DATE, DATE);   
 localCalendar.set(Calendar.MONTH, MONTH);   
 localCalendar.set(Calendar.YEAR, YEAR);       
 localCalendar.set(Calendar.HOUR_OF_DAY, HOUR_OF_DAY);               // 0..23   
 localCalendar.set(Calendar.MINUTE, MINUTE);   
 //localCalendar.set(Calendar.SECOND, SECOND);   
    
 BVLog.error("I'n in TimeZoneUtil--&amp;gt;"+localCalendar.getTime().toString());   
 if(serverTimeZone !=null){   
 serverCalendar=new GregorianCalendar(TimeZone.getTimeZone(serverTimeZone),Locale.ENGLISH);   
 }   
 else{   
 BVLog.error("I'n in TimeZoneUtil Else Part");   
 serverCalendar=new GregorianCalendar();     
 }   
 serverCalendar.setTimeInMillis(localCalendar.getTimeInMillis());   
 BVLog.error("I'n in TimeZoneUtil serverCalendar --&amp;gt;"+serverCalendar.getTime().toString());   
 return serverCalendar;   
}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Jul 2011 06:10:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/date-and-time-format-in-utc-java-udf/qaa-p/8027205#M2864857</guid>
      <dc:creator>former_member854360</dc:creator>
      <dc:date>2011-07-14T06:10:21Z</dc:date>
    </item>
    <item>
      <title>Re: Date and Time format in UTC java UDF</title>
      <link>https://community.sap.com/t5/technology-q-a/date-and-time-format-in-utc-java-udf/qaa-p/8027206#M2864858</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;I saw two of these in a Java forum...could not make it work...&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;My input is example 1994-11-05T08:15:30-05:00   I have to convert that to 1994-11-05T13:15:30Z (output is in UTC)&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Jul 2011 06:17:55 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/date-and-time-format-in-utc-java-udf/qaa-p/8027206#M2864858</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-14T06:17:55Z</dc:date>
    </item>
    <item>
      <title>Re: Date and Time format in UTC java UDF</title>
      <link>https://community.sap.com/t5/technology-q-a/date-and-time-format-in-utc-java-udf/qaa-p/8027207#M2864859</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kiran,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;You need to know your input timeZone as well.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Please let me know your input timeZone i will give you the Exact code.&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Jul 2011 06:20:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/date-and-time-format-in-utc-java-udf/qaa-p/8027207#M2864859</guid>
      <dc:creator>former_member854360</dc:creator>
      <dc:date>2011-07-14T06:20:36Z</dc:date>
    </item>
    <item>
      <title>Re: Date and Time format in UTC java UDF</title>
      <link>https://community.sap.com/t5/technology-q-a/date-and-time-format-in-utc-java-udf/qaa-p/8027208#M2864860</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;CHK THIS:&lt;/P&gt;&lt;P&gt;input will be var1&lt;/P&gt;&lt;P&gt;execution type: single value..&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;

String date1="";
String date2="";
String date3="";
    date1=var1.substring(0,10);
    date2=var1.substring(11,19);
   date3=date1+"T"+date2+"Z";
return date3;

&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Mapping:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Date -&amp;gt; UDF -&amp;gt; Output Date&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Jul 2011 06:20:41 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/date-and-time-format-in-utc-java-udf/qaa-p/8027208#M2864860</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-14T06:20:41Z</dc:date>
    </item>
    <item>
      <title>Re: Date and Time format in UTC java UDF</title>
      <link>https://community.sap.com/t5/technology-q-a/date-and-time-format-in-utc-java-udf/qaa-p/8027209#M2864861</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Company is in US so it will be EST&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Jul 2011 06:25:36 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/date-and-time-format-in-utc-java-udf/qaa-p/8027209#M2864861</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-14T06:25:36Z</dc:date>
    </item>
    <item>
      <title>Re: Date and Time format in UTC java UDF</title>
      <link>https://community.sap.com/t5/technology-q-a/date-and-time-format-in-utc-java-udf/qaa-p/8027210#M2864862</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Amitsri , thanks but this looks normal concating z to the existing one .....I have to add +4 hours to existing time ..that means iam converting input to UTC format...thanks&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Jul 2011 06:33:16 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/date-and-time-format-in-utc-java-udf/qaa-p/8027210#M2864862</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-14T06:33:16Z</dc:date>
    </item>
    <item>
      <title>Re: Date and Time format in UTC java UDF</title>
      <link>https://community.sap.com/t5/technology-q-a/date-and-time-format-in-utc-java-udf/qaa-p/8027211#M2864863</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kran,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I have tested this code.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here you go for your exact requirement.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Your input should be only one to this UDF &lt;STRONG&gt;p_localDateTime&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;And do use substring to provide the input to dd-MM-yyyy HH:mm:ss format before passing it to the UDF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Example : 1994-11-05T08:15:30-05:00&lt;/STRONG&gt;  Use substring and concat to convert it to &lt;STRONG&gt;dd-MM-yyyy HH:mm:ss&lt;/STRONG&gt;  format &lt;STRONG&gt;1994-11-05 08:15:30&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt; Also in Function tab of message mapping editor import the additional thing.&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;java.text.SimpleDateFormat&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;java.util.Date&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
public String converttoUTC(String p_localDateTime, Container container) throws StreamTransformationException{
String lv_dateFormateInUTC="";//Will hold the final converted date   
Date lv_localDate = null;   
String lv_localTimeZone ="";   
SimpleDateFormat lv_formatter;   
SimpleDateFormat lv_parser;   
    

  
//create a new Date object using the timezone of the specified city   
lv_parser = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");   
lv_parser.setTimeZone(TimeZone.getTimeZone("EST"));   
try
{
lv_localDate = lv_parser.parse(p_localDateTime);   
}
catch (java.text.ParseException e) 
{
}
  
//Set output format prints "2007/10/25  18:35:07 EDT(-0400)"   
lv_formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss z'('Z')'");   
lv_formatter.setTimeZone(TimeZone.getTimeZone(lv_localTimeZone));   
  
  
  
//Convert the date from the local timezone to UTC timezone   
lv_formatter.setTimeZone(TimeZone.getTimeZone("UTC"));   
lv_dateFormateInUTC = lv_formatter.format(lv_localDate);   

  
  
return lv_dateFormateInUTC;  
}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Jul 2011 06:49:12 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/date-and-time-format-in-utc-java-udf/qaa-p/8027211#M2864863</guid>
      <dc:creator>former_member854360</dc:creator>
      <dc:date>2011-07-14T06:49:12Z</dc:date>
    </item>
    <item>
      <title>Re: Date and Time format in UTC java UDF</title>
      <link>https://community.sap.com/t5/technology-q-a/date-and-time-format-in-utc-java-udf/qaa-p/8027212#M2864864</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi I tried but iam getting this error:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;'class' or 'interface' expected ^&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Iam using the code as below:&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Imports&lt;/STRONG&gt; java.util.Date;java.text.SimpleDateFormat;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;public&lt;/STRONG&gt; String UTC(String p_localDateTime ,Container container){&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;String lv_dateFormateInUTC="";//Will hold the final converted date   &lt;/P&gt;&lt;P&gt;Date lv_localDate = null;   &lt;/P&gt;&lt;P&gt;String lv_localTimeZone ="";   &lt;/P&gt;&lt;P&gt;SimpleDateFormat lv_formatter;   &lt;/P&gt;&lt;P&gt;SimpleDateFormat lv_parser;   &lt;/P&gt;&lt;P&gt;    &lt;/P&gt;&lt;P&gt; &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;//create a new Date object using the timezone of the specified city   &lt;/P&gt;&lt;P&gt;lv_parser = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");   &lt;/P&gt;&lt;P&gt;lv_parser.setTimeZone(TimeZone.getTimeZone("EST"));   &lt;/P&gt;&lt;P&gt;try&lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;lv_localDate = lv_parser.parse(p_localDateTime);   &lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;catch (java.text.ParseException e) &lt;/P&gt;&lt;P&gt;{&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;//Set output format prints "2007/10/25  18:35:07 EDT(-0400)"   &lt;/P&gt;&lt;P&gt;lv_formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss z'('Z')'");   &lt;/P&gt;&lt;P&gt;lv_formatter.setTimeZone(TimeZone.getTimeZone(lv_localTimeZone));   &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;System.out.println("convertLocalTimeToUTC: "&lt;EM&gt;p_city&lt;/EM&gt;": "+" The Date in the local time zone " + lv_formatter.format(lv_localDate));   &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;//Convert the date from the local timezone to UTC timezone   &lt;/P&gt;&lt;P&gt;lv_formatter.setTimeZone(TimeZone.getTimeZone("UTC"));   &lt;/P&gt;&lt;P&gt;lv_dateFormateInUTC = lv_formatter.format(lv_localDate);   &lt;/P&gt;&lt;P&gt;System.out.println("convertLocalTimeToUTC: "&lt;EM&gt;p_city&lt;/EM&gt;": "+" The Date in the UTC time zone " + lv_dateFormateInUTC);   &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;  &lt;/P&gt;&lt;P&gt;return lv_dateFormateInUTC;&lt;/P&gt;&lt;P&gt;}&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Jul 2011 07:05:47 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/date-and-time-format-in-utc-java-udf/qaa-p/8027212#M2864864</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-14T07:05:47Z</dc:date>
    </item>
    <item>
      <title>Re: Date and Time format in UTC java UDF</title>
      <link>https://community.sap.com/t5/technology-q-a/date-and-time-format-in-utc-java-udf/qaa-p/8027213#M2864865</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kiran,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dont write import statement in UDF.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;In function tab of message mapping editor add it under the standard imports.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Click on + sign and add to addtinal import.Also dont write &lt;STRONG&gt;import&lt;/STRONG&gt; statement in prefix to it&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Only write&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;java.text.SimpleDateFormat&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;java.util.Date.*&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Also find the Updated UDF .&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Here you dont need to use any sybstring or Concat &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;INPUT to UDF: 1994-11-05T08:15:30-05:00&lt;/P&gt;&lt;P&gt;OUTPUT from UDF: 1994-11-05T13:15:30Z &lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
public String calculate(String p_localDateTime, Container container) throws StreamTransformationException{
String lv_dateFormateInUTC="";//Will hold the final converted date   
Date lv_localDate = null;   
String lv_localTimeZone ="";   
SimpleDateFormat lv_formatter;   
SimpleDateFormat lv_parser;   

String date1="";
String date2="";
String date3="";
    date1=p_localDateTime.substring(0,10);
    date2=p_localDateTime.substring(11,19);
   date3=date1+" "+date2;


    

  
//create a new Date object using the timezone of the specified city   
lv_parser = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");   
lv_parser.setTimeZone(TimeZone.getTimeZone("EST"));   
try
{
lv_localDate = lv_parser.parse(date3);   
}
catch (java.text.ParseException e) 
{
}
  
//Set output format prints "2007/10/25  18:35:07 EDT(-0400)"   
lv_formatter = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss z'('Z')'");   
lv_formatter.setTimeZone(TimeZone.getTimeZone(lv_localTimeZone));   
  
  
  
//Convert the date from the local timezone to UTC timezone   
lv_formatter.setTimeZone(TimeZone.getTimeZone("UTC"));   
lv_dateFormateInUTC = lv_formatter.format(lv_localDate);   

   date1="";
 date2="";
date3="";
    date1=lv_dateFormateInUTC.substring(0,10);
    date2=lv_dateFormateInUTC.substring(11,19);
   date3=date1+"T"+date2+"Z";
return date3;
}&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Debashish on Jul 14, 2011 9:13 AM&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Edited by: Debashish on Jul 14, 2011 9:18 AM&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Jul 2011 07:09:04 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/date-and-time-format-in-utc-java-udf/qaa-p/8027213#M2864865</guid>
      <dc:creator>former_member854360</dc:creator>
      <dc:date>2011-07-14T07:09:04Z</dc:date>
    </item>
    <item>
      <title>Re: Date and Time format in UTC java UDF</title>
      <link>https://community.sap.com/t5/technology-q-a/date-and-time-format-in-utc-java-udf/qaa-p/8027214#M2864866</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Thanks for this..this is almost there ....but its converting 1994-11-05 08:15:30   to 17-04-0011T13:15:30Z&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Jul 2011 07:20:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/date-and-time-format-in-utc-java-udf/qaa-p/8027214#M2864866</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-14T07:20:15Z</dc:date>
    </item>
    <item>
      <title>Re: Date and Time format in UTC java UDF</title>
      <link>https://community.sap.com/t5/technology-q-a/date-and-time-format-in-utc-java-udf/qaa-p/8027215#M2864867</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi Kiran,&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Dont use any substring or concat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Directly provide &lt;STRONG&gt;1994-11-05T08:15:30-05:00&lt;/STRONG&gt; as input to the UDF without any conversion  and enjoy..........&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Jul 2011 07:22:22 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/date-and-time-format-in-utc-java-udf/qaa-p/8027215#M2864867</guid>
      <dc:creator>former_member854360</dc:creator>
      <dc:date>2011-07-14T07:22:22Z</dc:date>
    </item>
    <item>
      <title>Re: Date and Time format in UTC java UDF</title>
      <link>https://community.sap.com/t5/technology-q-a/date-and-time-format-in-utc-java-udf/qaa-p/8027216#M2864868</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;nah still same 17-04-0011T13:15:30Z&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Jul 2011 07:25:39 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/date-and-time-format-in-utc-java-udf/qaa-p/8027216#M2864868</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-14T07:25:39Z</dc:date>
    </item>
    <item>
      <title>Re: Date and Time format in UTC java UDF</title>
      <link>https://community.sap.com/t5/technology-q-a/date-and-time-format-in-utc-java-udf/qaa-p/8027217#M2864869</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Sorry Kiran,&lt;/P&gt;&lt;P&gt;use this and please let me know if it works.&lt;/P&gt;&lt;P&gt;Problem was because of dateformat.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;String lv_dateFormateInUTC="";//Will hold the final converted date   
Date lv_localDate = null;   
String lv_localTimeZone ="";   
SimpleDateFormat lv_formatter;   
SimpleDateFormat lv_parser;   

String date1="";
String date2="";
String date3="";
    date1=p_localDateTime.substring(0,10);
    date2=p_localDateTime.substring(11,19);
   date3=date1+" "+date2;


    

  
//create a new Date object using the timezone of the specified city   
lv_parser = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");   
lv_parser.setTimeZone(TimeZone.getTimeZone("EST"));   
try
{
lv_localDate = lv_parser.parse(date3);   
}
catch (java.text.ParseException e) 
{
}
  
//Set output format prints "2007/10/25  18:35:07 EDT(-0400)"   
lv_formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss z'('Z')'");   
lv_formatter.setTimeZone(TimeZone.getTimeZone(lv_localTimeZone));   
  
  
  
//Convert the date from the local timezone to UTC timezone   
lv_formatter.setTimeZone(TimeZone.getTimeZone("UTC"));   
lv_dateFormateInUTC = lv_formatter.format(lv_localDate);   

 date1="";
 date2="";
date3="";
    date1=lv_dateFormateInUTC.substring(0,10);
    date2=lv_dateFormateInUTC.substring(11,19);
   date3=date1+"T"+date2+"Z";
return date3;&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Jul 2011 07:32:34 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/date-and-time-format-in-utc-java-udf/qaa-p/8027217#M2864869</guid>
      <dc:creator>former_member854360</dc:creator>
      <dc:date>2011-07-14T07:32:34Z</dc:date>
    </item>
    <item>
      <title>Re: Date and Time format in UTC java UDF</title>
      <link>https://community.sap.com/t5/technology-q-a/date-and-time-format-in-utc-java-udf/qaa-p/8027218#M2864870</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;hey cool man , you nailed it...got the final one...I might have to twaek it a bit after i get exact format..thanks dude.....&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Thu, 14 Jul 2011 07:59:21 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/date-and-time-format-in-utc-java-udf/qaa-p/8027218#M2864870</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2011-07-14T07:59:21Z</dc:date>
    </item>
    <item>
      <title>Re: Date and Time format in UTC java UDF</title>
      <link>https://community.sap.com/t5/technology-q-a/date-and-time-format-in-utc-java-udf/qaa-p/8027219#M2864871</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;&lt;SPAN class="j-post-author"&gt;&lt;STRONG&gt;Former Member&lt;/STRONG&gt;Former Member&lt;STRONG&gt;Former Member&lt;/STRONG&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="hps"&gt;I have the same&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;problem&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;on the date,&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;how you solved&lt;/SPAN&gt; &lt;SPAN class="hps"&gt;with the UDF function?&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="hps"&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="hps"&gt;thanks&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="hps"&gt;umberto&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN lang="en"&gt;&lt;SPAN class="hps"&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Mon, 23 Jun 2014 13:38:11 GMT</pubDate>
      <guid>https://community.sap.com/t5/technology-q-a/date-and-time-format-in-utc-java-udf/qaa-p/8027219#M2864871</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2014-06-23T13:38:11Z</dc:date>
    </item>
  </channel>
</rss>

