Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi Everyone,
I stuck in date format from source system to target system in Java component.
We would like to know how to convert string to date format 2019-08-22T00:00:00.000-07:00.
We tried
import java.text.SimpleDateFormat; import java.util.Date; public class Main { public static void main(String args[]) throws Exception { SimpleDateFormat ft = new SimpleDateFormat("yyyy-MM-dd hh:mm:ss"); String input = "2019-08-22T00:00:00.000-07:00"; System.out.print(input + " Parses as "); Date t = ft.parse(input); System.out.println(t); } }
Any help would be much appreciated. Thanks in advance.
Hi,
The timestamp format "2019-08-22T00:00:00.000-07:00" has T as separator between date and time, whereas ".000" after seconds defines nano seconds. At the end "-07:00" referred as timezone.
Now considering these terms and applying in our date pattern as below:
TalendDate.parseDateInUTC("yyyy-MM-dd'T'HH:mm:ss.SSS'-07:00'", "2019-08-22T00:00:00.000-07:00")
You can further format this date using TalendDate.formatDateInUTC().
Considering the fact that the timezone remains constant(-07:00) in all incoming records.
Thanks
Hi,
The timestamp format "2019-08-22T00:00:00.000-07:00" has T as separator between date and time, whereas ".000" after seconds defines nano seconds. At the end "-07:00" referred as timezone.
Now considering these terms and applying in our date pattern as below:
TalendDate.parseDateInUTC("yyyy-MM-dd'T'HH:mm:ss.SSS'-07:00'", "2019-08-22T00:00:00.000-07:00")
You can further format this date using TalendDate.formatDateInUTC().
Considering the fact that the timezone remains constant(-07:00) in all incoming records.
Thanks