cancel
Showing results for 
Search instead for 
Did you mean: 

UDF to convert input date into CST timezone

Former Member
0 Kudos

Hi All,

I am working on Proxy to SOAP synchronous interface. We are receiving a timestamp value in response as 2015-09-30T06:18:08-05:00.

Our requirement is to convert the incoming timestamp (2015-09-30T06:18:08-05:00) to CST timezone (2015-09-30T11:18:08).

Please help me with UDF to get the same.

Thanks,

Nida Fatima

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Hi Nida

I am a bit confused with you requirement when you say date/time "2015-09-30T06:18:08-05:00" this means it is already in CST, so if you convert this into CST the output will be "2015-09-30T06:18:08".

But you mentioned output should be "2015-09-30T11:18:08" which will be UTC according to above CST date.

Also Timezones will not come : so your it will be "-0500" not "-05:00" .

But still try this below code and let me know if this works.

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

DateFormat outputFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");

try{

Date date = inputFormat.parse(inTimeStr);

outputFormat.setTimeZone(TimeZone.getTimeZone("UTC"));

return outputFormat.format(date);

}catch(Exception e){

return "you error";

}

Note: add "java.text.*" in import section.

Former Member
0 Kudos

Thanks Osman. Your code worked for me.

Regards,

Nida

Answers (1)

Answers (1)

Former Member
0 Kudos