Talend日期:将EST时间解析为UTC

时间:2019-01-10 12:31:15

标签: java bigdata talend

我正在尝试将EST时间解析为UTC,但是低于错误

[statistics] connected    
Exception in component tMap_3 (sample)    
java.lang.RuntimeException: java.text.ParseException: Unparseable date: ""    
    at routines.TalendDate.parseDate(TalendDate.java:898)    
    at routines.TalendDate.parseDate(TalendDate.java:842)   
    at local_project.sample_0_1.sample.tFileInputDelimited_3Process(sample.java:2271)    
    at local_project.sample_0_1.sample.tFileList_2Process(sample.java:3219)    
    at local_project.sample_0_1.sample.tFileList_1Process(sample.java:2872)    
    at local_project.sample_0_1.sample.runJobInTOS(sample.java:3514)     
    at local_project.sample_0_1.sample.main(sample.java:3365)    
Caused by: java.text.ParseException: Unparseable date: ""    
    at java.text.DateFormat.parse(Unknown Source)    
    at routines.TalendDate.parseDate(TalendDate.java:884)    
    ... 6 more    

我使用tMap进行融合

TalendDate.formatDateInUTC("MM/dd/yyyy HH:mm aa",TalendDate.parseDate( "MM/dd/yyyy HH:mm aa",row9.Start_time))

预期输出:

Input string : 1/2/2019 8:50 AM EST    
Expected String : 1/2/2019 1:50 PM UTC  

1 个答案:

答案 0 :(得分:0)

java.lang.RuntimeException: java.text.ParseException: Unparseable date: ""

在这一行中,您可以看到为函数TalendDate.parseDate提供的值为“”,这是一个空字符串。这意味着row9.Start_time为空,并且该函数无法解析空字符串,这就是为什么会出现异常的原因。

请确保值row9.Start_time的填充正确,或添加if子句以避免解析为空的日期。您可以尝试这样的事情:

(row9.Start_time == null || "".equals(row9.Start_time)) ? "" : TalendDate.formatDateInUTC("MM/dd/yyyy HH:mm aa",TalendDate.parseDate( "MM/dd/yyyy HH:mm aa",row9.Start_time))

希望这会有所帮助。