我需要在NiFi中转换日期:
2022-11-22 : 00:00:00
至:
2022-11-22T00:00:00.000Z (ISO 8601)
谁能帮我改一下这个日期吗?
发布于 2022-11-22 14:51:31
可以在JoltTransformJSON
处理器中使用以下规范,假定需要转换属性的当前值(即嵌套在简单JSON对象中的dt
),即从变量$now
提取的2022-11-22 00:00:00
[
{
// reformat by adding the milliseconds option
"operation": "default",
"spec": {
"dt": "${now():format('yyyy-MM-ddHH:mm:ss.SSS')}"
}
},
{
// split and recombine the pieces of the attribute's value
"operation": "modify-overwrite-beta",
"spec": {
"date": "=substring(@(1,dt),0,10)",
"time": "=substring(@(1,dt),10,22)",
"dt":"=concat(@(1,date),'T',@(1,time),'Z')"
}
},
{
// pick only theoriginal tag name
"operation": "shift",
"spec": {
"dt": "&"
}
}
]
发布于 2022-11-23 11:53:36
如果您(或可以)将此信息作为属性,您可以使用NiFi的表达式语言来转换它。
例如,使用这样的方法:${my_attribute:toDate("yyyy-MM-dd HH:mm:ss", "Europe/Paris"):format("yyyy-MM-dd'T'HH:mm:ss'Z'")}
https://stackoverflow.com/questions/74533645
复制相似问题