Unable to write exact time

Hi have json like below
[
{
“id”: 309767,
“testExecKey”: “TEST81313-1307”,
“testKey”: “TEST81313-1287”,
“status”: “EXECUTING”,
“type”: “Manual”,
“start”: “2023-05-24T07:46:18+02:00”,
“executedBy”: “rupmore”,
“defects”: ,
“evidences”: [
{
“filename”: “CAP-66666.csv”,
“contentType”: “text/csv”,
“data”: “https://e-3d-jira2.capgemi****chment/219483/CAP-66666.csv”
}
],
“steps”: [
{
“status”: “TODO”,
“defects”: ,
“evidences”:
},
{
“status”: “TODO”,
“defects”: ,
“evidences”:
}
],
“assignee”: “rupmore”,
“testEnvironments”: ,
“iterations”: ,
“comment”: “Test case is aborted”
},
{
“id”: 309768,
“testExecKey”: “TEST81313-1307”,
“testKey”: “TEST81313-1288”,
“status”: “EXECUTING”,
“type”: “Manual”,
“start”: “2023-05-24T07:46:13+02:00”,
“executedBy”: “rupmore”,
“defects”: ,
“evidences”: ,
“steps”: ,
“assignee”: “rupmore”,
“testEnvironments”: ,
“iterations”:
}
]

here 2 start dates are there.
1]2023-05-24T07:46:18+02:00
2] 2023-05-24T07:46:13+02:00

steps i am doing -
desrialize json and storing in “jrez” variable
to acess start date i am doing - " ““start””:“”“+Jrez(Counter4)(“start”).Value(Of DateTime).ToString(“yyyy-MM-ddTHH:mm:ssk”)+”“”“+”,"

consider value of counter 4 is o
means only from below block
{
“id”: 309767,
“testExecKey”: “TEST81313-1307”,
“testKey”: “TEST81313-1287”,
“status”: “EXECUTING”,
“type”: “Manual”,
“start”: “2023-05-24T11:16:18+05:30”,
“executedBy”: “rupmore”,
“defects”: ,
“evidences”: [
{
“filename”: “CAP-66666.csv”,
“contentType”: “text/csv”,
“data”: “https://e-3d-jira2.capgemi****chment/219483/CAP-66666.csv”
}
],
“steps”: [
{
“status”: “TODO”,
“defects”: ,
“evidences”:
},
{
“status”: “TODO”,
“defects”: ,
“evidences”:
}
],
“assignee”: “rupmore”,
“testEnvironments”: ,
“iterations”: ,
“comment”: “Test case is aborted”
}

which wil return 2023-05-24T07:46:18+02:00 - expected

as i am appending in json file using append line and using above expression
" ““start””:“”“+Jrez(Counter4)(“start”).Value(Of DateTime).ToString(“yyyy-MM-ddTHH:mm:ssk”)+”“”“+”,"

it writing date correct but time it is taking wrong it is writing
2023-05-24T11:16:18k - i am getting

i am running this on VM where datetime is different than local machine.
How can i get exact date.
update me if you have any query reagrding requirement.
You can find below input and expected output file.
TEST81313-1307 Input.json (1.1 KB)
TEST81313-1307 Output.json (1.2 KB)

@Silviu @devashish1989 @bcorrea @marian.platonov @Josh_James @vaishnavi_baradkar

@Mathkar_kunal

Give an sample Input and required output.
Regards,

you can find below
TEST81313-1307 Input.json (1.1 KB)
TEST81313-1307 Output.json (1.2 KB)

Cross Reference:

Hi @Mathkar_kunal

Try this syntax:

"""start"":""" + DateTimeOffset.Parse(Jrez(Counter4)("start").ToString()).ToLocalTime().ToString("yyyy-MM-ddTHH:mm:ssK") + ""","

It will give the expected output.
Regards,

still missmatch
expected


getting

Hi @Mathkar_kunal

Try this:

"""start"":""" + DateTimeOffset.ParseExact(Jrez(Counter4)("start").ToString, "yyyy-MM-ddTHH:mm:ssK", System.Globalization.CultureInfo.InvariantCulture).ToLocalTime().ToString("yyyy-MM-ddTHH:mm:ssK") + ""","

Hope it works!!

@Mathkar_kunal

The time you are getting is in a different locale…the time is getting changed as per the ypur timezone…in the given time the timezone is for +2 and your timezone might be different

Also if you want only the given time then split the data on + and then get only the time and without locale and convert it…then you wuld get the same time as you need

Cheers

can you please explain in details or provide me steps i have provided json

@Mathkar_kunal

Try this

Cdate(Jrez(Counter4)("start").ToString.Split({"+"},Stringsplitoptions.None)(0).Replace("T"," "))

Cheers

tried but same as previous value i a getting
can we conenct on google meet?

can i saperate and again update in my file it will work?

can we do something using TimeZoneInfo.ConvertTimeFromUtc
??

@Mathkar_kunal

Can you print the original string you are getting using log message please

cheers

original string in json is this as i mentioned in earlear
{
“id”: 309767,
“testExecKey”: “TEST81313-1307”,
“testKey”: “TEST81313-1287”,
“status”: “EXECUTING”,
“type”: “Manual”,
“start”: “2023-05-24T07:46:18+02:00”,
“executedBy”: “rupmore”,
“defects”: ,
“evidences”: [
{
“filename”: “CAP-66666.csv”,
“contentType”: “text/csv”,
“data”: “https://e-3d-jira2.capgemi****chment/219483/CAP-66666.csv”
}
],
“steps”: [
{
“status”: “TODO”,
“defects”: ,
“evidences”:
},
{
“status”: “TODO”,
“defects”: ,
“evidences”:
}
],
“assignee”: “rupmore”,
“testEnvironments”: ,
“iterations”: ,
“comment”: “Test case is aborted”
}

here u can see start date is “2023-05-24T07:46:18+02:00”, thsi i want exact mesage when i am appending data to another file like below
“start”: “2023-05-24T11:16:18k”,

@Mathkar_kunal

please check how you are trying. It is giving as expected the same time

image

cheers

i am reading json (original file) using deserialize array and writinga fter rearranging in specific format . when it is wriring it is taking vm format while reading.
can we connect on google meet?

if suppose this value is in json how can you copy as it is?
values are changing after doing desreialization

@Mathkar_kunal

after deserialize if you use .ToString instead of converting to date directly then you will get it proper I believe…can you check

cheers

will not be changed when the serialization is configured as explained within the cross-referenced topic