
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Convert UTC date to US Central Time
I am reading data from Salesforce objects. It has a date field in UTC format as shown below. How do i convert this date into US Central Time when loading into a file?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
maybe TalendDate.parseDateLocale("EEE MMM dd HH:mm:ss z yyyy", String.valueOf(input_row.newColumn),"en-US");
Send me Love and kudos

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Thanks! It appears that it doesn't convert to central time. Please see below, the left field is the input date in UTC and the right field is the converted date using the above code.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Maybe you can refer to this topic :
https://community.talend.com/s/feed/0D73p000004kZwJCAU?language=en_US
@Fred Trebuchet made a custom routine to convert utc to local time.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
so you can write this routine :
package routines;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.TimeZone;
public class TimeConvert {
public static Date convertTzToTz(String strDate, String inTz, String outTz) throws Exception
{
if (strDate == null || inTz == null || outTz == null)
return null;
// Convert strDate from any valid timezone such Europe/Paris to another one
// strDate is expected to be formatted as "yyyy-MM-ddTHH:mm:ssZ"
SimpleDateFormat indfm = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss");
indfm.setTimeZone(TimeZone.getTimeZone(inTz));
Date inDate = indfm.parse(strDate);
SimpleDateFormat outdfm = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ssZ");
outdfm.setTimeZone(TimeZone.getTimeZone(outTz));
return TalendDate.parseDate("yyyy-MM-dd'T'HH:mm:ssZ",outdfm.format(inDate));
}
}
and call it in your job :
TimeConvert.convertTzToTz((your input column),"UTC","US/Central");
your input date have to be in string format and the output will be a date with the pattern you want in the output schema of the component :
if your input is in date format :
TimeConvert.convertTzToTz(TalendDate.formatDate("yyyy-MM-dd'T'HH:mm:ss.SSS'Z'",(your input)),"UTC","US/Central");
here is the result :
input :
2021-07-15T17:54:39.000Z
2021-07-15T17:54:48.000Z
output:
15-07-2021 12:54:39
15-07-2021 12:54:48

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi @anshumali ambasht , did you solve your issue ?
If one of my answer help you to achieve it, please select it as best answer.
Send me love and kudos
