Reputation: 1304
I have strings with ISO 8601 timestamps like 2016-03-07T10:02:37.820+01:00
and I would like to convert them to UTC time. The built-in to_utc_timestamp
(AFAIK) only takes time zone names (e.g. PST, CET) and not the offsets. At least I tried and failed. Is there an elegant way to achieve this in Hive?
Upvotes: 1
Views: 4208
Reputation: 20820
One way is, you can write a Hive UDF for time format conversion.
Another way is, convert ISO timestamps to seconds using unix_timestamp
and then use to_utc_timestamp
TO_UTC_TIMESTAMP(UNIX_TIMESTAMP(T.date, "yyyy-MM-dd'T'hh:mm:ss.SSS'Z'") * 1000, '<timezone>')
Upvotes: 1