我使用sqoop将带有选定列的表导入到avro文件格式。使用avro-tools将日期以奇怪的格式显示(negetive)。我怎么才能破解日期?
{"first_name":{"string":"Mary"},"last_name": {"string":"Botman"},"birth_date":{"long":-345772800000}}作为MySQL查询的五种正确格式
mysql> select first_name, last_name, birth_date from employees where first_name like 'Mary' and last_name ='Botman';
+------------+-----------+------------+
| first_name | last_name | birth_date |
+------------+-----------+------------+
| Mary | Botman | 1959-01-17 |
+------------+-----------+------------+
1 row in set (0.07 sec)发布于 2018-02-13 18:22:24
长值-345772800000代表.
自被称为“时代”的标准基准时间起的毫秒数,即1970年1月1日00:00:00格林尼治时间1970年1月1日起的毫秒数
在你的例子中,它是一个负值,所以它从“时代”倒计时。在Java代码中,您可以如下所示从这个值创建一个LocalDate,这将给出与您的Hive查询结果相同的结果。
LocalDate date17Jan1959 = Instant.ofEpochMilli(-345772800000L)
.atZone(ZoneOffset.UTC)
.toLocalDate();https://stackoverflow.com/questions/42688388
复制相似问题