Home > Enterprise >  How to change timezone with Offset when Deserializing DateTime using JSON.NET in Azure APIM?
How to change timezone with Offset when Deserializing DateTime using JSON.NET in Azure APIM?

Time:01-11

I'm using Azure APIM policy expression to aggregate multiple responses. In that one of the JSON response contains multiple dateTime fields. all of them are in UTC TZ. I want to deserialize all of the date fields to specific Timezone(in my case SGT 08:00) from 00:00

Input:

{
    "Header": {
        "UserID": "xxxxxx",
        "MessageID": "xxxxxx",
        "CorrelationID": "xxxx",
        "DateTime": "2018-02-12T15:31:18 00:00",
        "ReqID": "xxx"
    },
    "ResultSet": {
        "Tier": {
            "CardSuffix": "91",
            "RetentionDeadline": "2022-02-27T16:00:00 00:00",
            "PointsRequireToQualify": "xxxxx",
            "QualifyingDeadline": "2022-02-27T16:00:00 00:00",
            "SignupDate": "2020-08-07",
            "IssuedDate": "2021-06-15",
            "JoiningDateTime": "2010-03-31T10:10:00 00:00",
            "RequireToUpgradeInYear": "288886",
            "YearlyUpgradeDeadline": "2022-02-27T16:00:00 00:00",
            "CurrentCardDesc": "xxxxxxxx",
            "NextCardDesc": "xxxxxxxxx",
            "CurrentTierPoints": "0",
            "UpdatedDateTime": "2023-01-09T17:43:54.844 00:00",
            "LastRefreshedDateTime": "2022-02-10T07:45:13 00:00"
        }
    }
}

Expected Output:

{
    "Header": {
        "UserID": "xxxxxx",
        "MessageID": "xxxxxx",
        "CorrelationID": "xxxx",
        "DateTime": "2018-02-12T15:31:18 08:00",
        "ReqID": "xxx"
    },
    "ResultSet": {
        "Tier": {
            "CardSuffix": "91",
            "RetentionDeadline": "2022-02-28T0:00:00 08:00",
            "PointsRequireToQualify": "xxxxx",
            "QualifyingDeadline": "2022-02-28T0:00:00 08:00",
            "SignupDate": "2020-08-07",
            "IssuedDate": "2021-06-15",
            "JoiningDateTime": "2010-03-31T10:10:00 08:00",
            "RequireToUpgradeInYear": "288886",
            "YearlyUpgradeDeadline": "2022-02-28T0:00:00 08:00",
            "CurrentCardDesc": "xxxxxxxx",
            "NextCardDesc": "xxxxxxxxx",
            "CurrentTierPoints": "0",
            "UpdatedDateTime": "2023-01-10T22:08:08 08:00",
            "LastRefreshedDateTime": "2022-02-10T15:45:13 08:00"
        }
    }
}

I have tried and achieved the expected output by using enter image description here

  • Related