Skip to main content
Announcements
See what Drew Clarke has to say about the Qlik Talend Cloud launch! READ THE BLOG
cancel
Showing results for 
Search instead for 
Did you mean: 
gt0731
Contributor III
Contributor III

Unparseable date: "2019-08-22T00:00:00.000-07:00"

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. 

 

 

 

 

Labels (3)
1 Solution

Accepted Solutions
hrishikesh_t
Contributor II
Contributor II

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

View solution in original post

1 Reply
hrishikesh_t
Contributor II
Contributor II

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