in my case, I am getting a json in which I need to modify the timestamp of today and then need to add some specific time (hardcoded), I'm trying it but everytime my json gets messed up.
Here is the json I'm getting -
{"offerId":"00000002","offerStatus":"A","startDate":"2023-01-13T00:00:00-05:00"}
I want to change the time of the start date is like this 2023-01-16T00:00:00-05:00 -- I used java.time.LocalDate.now().toString() function, but it only gives me the date, I want to add timezone hardcoded,
I tried this but it didn't work -
String expected = "{\"offerId\":\"00000002\",\"offerStatus\":\"A\",\"startDate\":"\"" java.time.LocalDate.now().toString() "T00:00:00-05:00\"};
how can I achieve that? thanks!
CodePudding user response:
Try to use ZonedDateTime
where you can pass your own zone offset.
Example: ZonedDateTime.now(ZoneOffset.UTC).toString()