gpt4 book ai didi

azure - Azure Logic APP EPOCH DATE 转换问题

转载 作者:行者123 更新时间:2023-12-03 01:17:27 27 4
gpt4 key购买 nike

我在 Azure 逻辑应用中遇到纪元日期转换问题。我无法弄清楚我在这里做错了什么。

我已将逻辑应用分为不同的步骤,首先获取时间戳并删除“/Date”和尾随的“/”。

然后我使用添加到时间函数,我得到了意想不到的结果。

输入:

"EndDate": "/Date(253402214400000)/",
"StartDate": "/Date(946684800000)/"

预期输出

 "EndDate"  : "2000-01-01T00:00:00",
"StartDate": "9999-12-31T00:00:00"

当前结果:

"EndDate": "1942-11-15T20:26:40.0000000Z",
"StartDate": "2026-10-14T16:21:20.0000000Z"

逻辑应用代码

{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Compose": {
"inputs": {
"root": {
"CostAccountID": "AD100",
"EndDate": "9999-12-31T00:00:00Z",
"StartDate": "2000-01-01T00:00:00Z"
}
},
"runAfter": {},
"type": "Compose"
},
"Compose_2": {
"inputs": {
"root": {
"CostAccountID": "@{body('Parse_JSON')?['root']?['CostAccountID']}",
"EndDate1": "@{int(replace(replace(body('Parse_JSON')?['root']?['EndDate'],'/Date(',''),')/',''))}",
"StartDate1": "@{int(replace(replace(body('Parse_JSON')?['root']?['StartDate'],'/Date(',''),')/',''))}"
}
},
"runAfter": {
"Parse_JSON": [
"Succeeded"
]
},
"type": "Compose"
},
"Compose_3": {
"inputs": {
"root": {
"CostAccountID": "@{body('Parse_JSON')?['root']?['CostAccountID']}",
"EndDate": "@{addToTime('1970-01-01T00:00:00Z', int(body('Parse_JSON_2')?['root']?['EndDate1']), 'Second')}",
"StartDate": "@{addToTime('1970-01-01T00:00:00Z', int(body('Parse_JSON_2')?['root']?['StartDate1']), 'Second')}"
}
},
"runAfter": {
"Parse_JSON_2": [
"Succeeded"
]
},
"type": "Compose"
},
"Parse_JSON": {
"inputs": {
"content": "@outputs('Compose')",
"schema": {
"properties": {
"root": {
"properties": {
"CostAccountID": {
"type": "string"
},
"EndDate": {
"type": "string"
},
"StartDate": {
"type": "string"
}
},
"type": "object"
}
},
"type": "object"
}
},
"runAfter": {
"Compose": [
"Succeeded"
]
},
"type": "ParseJson"
},
"Parse_JSON_2": {
"inputs": {
"content": "@outputs('Compose_2')",
"schema": {
"properties": {
"root": {
"properties": {
"CostAccountID": {
"type": "string"
},
"EndDate1": {
"type": "string"
},
"StartDate1": {
"type": "string"
}
},
"type": "object"
}
},
"type": "object"
}
},
"runAfter": {
"Compose_2": [
"Succeeded"
]
},
"type": "ParseJson"
},
"Response": {
"inputs": {
"body": "@outputs('Compose_2')",
"statusCode": 200
},
"kind": "http",
"runAfter": {
"Compose_3": [
"Succeeded"
]
},
"type": "Response"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"triggers": {
"manual": {
"inputs": {},
"kind": "Http",
"type": "Request"
}
}
},
"kind": "Stateful"
}

最佳答案

从我这边复制后,我们发现您使用了以毫秒为单位的值。尝试将其转换为秒并遵循相同的方法。下面是我正在使用的代码 -

{
"root": {
"CostAccountID": "@{body('Parse_JSON')?['root']?['CostAccountID']}",
"EndDate": "@{addSeconds('1970-01-01T00:00:00Z', div(int(body('Parse_JSON_2')?['root']?['EndDate1']),1000))}",
"StartDate": "@{addSeconds('1970-01-01T00:00:00Z', div(int(body('Parse_JSON_2')?['root']?['StartDate1']),1000))}"
}
}

结果:

enter image description here

我已对您的代码 View 进行了更改。以下是更新后的内容

{
"definition": {
"$schema": "https://schema.management.azure.com/providers/Microsoft.Logic/schemas/2016-06-01/workflowdefinition.json#",
"actions": {
"Compose": {
"inputs": {
"root": {
"CostAccountID": "AD100",
"EndDate": "/Date(253402214400000)/",
"StartDate": "/Date(946684800000)/"
}
},
"runAfter": {},
"type": "Compose"
},
"Compose_2": {
"inputs": {
"root": {
"CostAccountID": "@{body('Parse_JSON')?['root']?['CostAccountID']}",
"EndDate1": "@{int(replace(replace(body('Parse_JSON')?['root']?['EndDate'],'/Date(',''),')/',''))}",
"StartDate1": "@{int(replace(replace(body('Parse_JSON')?['root']?['StartDate'],'/Date(',''),')/',''))}"
}
},
"runAfter": {
"Parse_JSON": [
"Succeeded"
]
},
"type": "Compose"
},
"Compose_3": {
"inputs": {
"root": {
"CostAccountID": "@{body('Parse_JSON')?['root']?['CostAccountID']}",
"EndDate": "@{addSeconds('1970-01-01T00:00:00Z', div(int(body('Parse_JSON_2')?['root']?['EndDate1']),1000))}",
"StartDate": "@{addSeconds('1970-01-01T00:00:00Z', div(int(body('Parse_JSON_2')?['root']?['StartDate1']),1000))}"
}
},
"runAfter": {
"Parse_JSON_2": [
"Succeeded"
]
},
"type": "Compose"
},
"Parse_JSON": {
"inputs": {
"content": "@outputs('Compose')",
"schema": {
"properties": {
"root": {
"properties": {
"CostAccountID": {
"type": "string"
},
"EndDate": {
"type": "string"
},
"StartDate": {
"type": "string"
}
},
"type": "object"
}
},
"type": "object"
}
},
"runAfter": {
"Compose": [
"Succeeded"
]
},
"type": "ParseJson"
},
"Parse_JSON_2": {
"inputs": {
"content": "@outputs('Compose_2')",
"schema": {
"properties": {
"root": {
"properties": {
"CostAccountID": {
"type": "string"
},
"EndDate1": {
"type": "string"
},
"StartDate1": {
"type": "string"
}
},
"type": "object"
}
},
"type": "object"
}
},
"runAfter": {
"Compose_2": [
"Succeeded"
]
},
"type": "ParseJson"
},
"Response": {
"inputs": {
"body": "@outputs('Compose_3')",
"statusCode": 200
},
"kind": "http",
"runAfter": {
"Compose_3": [
"Succeeded"
]
},
"type": "Response"
}
},
"contentVersion": "1.0.0.0",
"outputs": {},
"parameters": {},
"triggers": {
"manual": {
"inputs": {},
"kind": "Http",
"type": "Request"
}
}
}
}

关于azure - Azure Logic APP EPOCH DATE 转换问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/74085936/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com