Reputation: 379
I have been trying to convert ISO date format ('2016-06-23T20:04:41.914Z') ,which is in string to date datatype .In Pig Docs,there is function ToDate which convert string into Date(this). So i tried it in different ways:
1.
b = FOREACH a GENERATE ToDate(status_date,'yyyy-MM-dd hh:mm:ss.SSS);
Error:
Caused by: java.lang.IllegalArgumentException: Invalid format: "2016-06-23T20:04:41.914Z" is malformed at "T20:04:41.914Z"
2.
b = FOREACH a GENERATE ToDate(status_date);
Error:
Caused by: java.lang.IllegalArgumentException: Invalid format: ""
3.
b = FOREACH a GENERATE ToDate(status_date,'yyyy-MM-ddThh:mm:ss.SSSZ');
Error:
Caused by: java.lang.IllegalArgumentException: Illegal pattern component: T
Please let me know if i am missing something or is there any other way other than writing udf and using concat. Also let me know if any additional information is required.
Upvotes: 0
Views: 331
Reputation: 34
The second method should work, your data have some record have field status_date is null?
Upvotes: 1