1

I want to add x number of days in a date with respect to my business hours. This is my code

I used

add(businessHoursId, startDate, intervalMilliseconds)

This is the snippet of code:

cNew.TAT_Target_DateTime_for_Pending__c = BusinessHours.add(cBHid, DateTimeNow, Math.abs(myTat.PendingTATms__c.intValue()));

cBHid = is my business hoursid

DateTimeNow = system.now

myTat.PendingTATms__c = custom setting data

I asserted it and it returned scientific notation

view image enter image description here

is there any way that I can add the milliseconds without exceeding the size of the intervalmilliseconds?

1
  • looks like your assert expected value is empty. Can you show more of your code please?
    – Novarg
    Commented Dec 20, 2017 at 7:52

1 Answer 1

2

intValue is limited to a maximum of 2,147,483,647 (231-1), resulting in a total expressed time of about 24.8 total days; if your business hours were 24 hours, you'd get about 3 weeks and 3 days before you rolled over. Instead, you will likely want to use longValue, which has twice as many bits (263-1), resulting in a maximum value of 9,223,372,036,854,775,807, or a total of about 292,277,024 years in total time.

cNew.TAT_Target_DateTime_for_Pending__c = 
    BusinessHours.add(cBHid, DateTimeNow, Math.abs(myTat.PendingTATms__c.longValue()));

You must log in to answer this question.

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