I'm creating a record in a test class that needs a specific LastModifiedDate, that date would be, today's date minus 365 days. When I create the record, this is what the code looks like:
String OppJSON = '{"attributes":{"type":"Opportunity","url":"/services/data/v25.0/sobjects/Opportunity/500E0000002nH2fIAE"},"Id":"500E0000002nH2fIAE","LastModifiedDate":"2015-01-06T17:54:26.000+0000"}';
Opportunity opp = (Opportunity) JSON.deserialize(OppJSON, Opportunity.class );
But I would like to instead of manually specify the datetime of LastModifiedDate to take today's date/time and substract 365 days. What would the syntax look like for this? I know I can do this:
Datetime oneyearago = System.today().addDays(-365);
String value = String.valueOf(oneyearago);
but I don't know how to use that value string in my json. Thanks in advanced.