0

I'm having a problem to add a UTC offset to a datetime value. For example I have the following value 2019-01-18T00:00:00.000+0000 but I must put this value in another field adding the UTC offset (-0300) to get something like this 2019-01-18T00:00:00.000-0300. How can I do that? It is a class so i have to use apex to do that.

1 Answer 1

0

Datetime includes methods such as addHours, addMinutes and addSeconds that you can use with positive or negative values.

For example:

Datetime value = System.now();
TimeZone to = TimeZone.getTimeZone('America/Argentina/Buenos_Aires');

value = value.addSeconds(to.getOffset(value) / 1000);

Note, however, the representation of date/time won't tell you this is in a specific time zone offset.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .