Been trying to solve this for almost two weeks. I'm importing a date string from a CSV, something like 12/16/16. I want to put this date into the Tasks object Activity Date field, which is Date/Time. However, for the life of me, I can not get any conversion methods I've researched here to work. I always end up with the error of:
Illegal Assignment from Datetime to Date
Here's the portion of code where I'm trying to address the issue. I'm not a developer by trade, just trying to help some users do some things.
tskstoupload = new List<Task>();
for (Integer i=1;i<filelines.size();i++)
{
String[] inputvalues = new String[]{};
inputvalues = filelines[i].split(',');
Date ad = Date.valueOf(inputvalues[1]);
String dt = DateTime.newInstance(ad.year(), ad.month(), ad.day()).format('YYYY-MM-dd');
Datetime acd = DateTime.valueOf(dt);
Task t = new Task();
t.WhoId = inputvalues[0];
t.ActivityDate = acd;
t.Subject = inputvalues[2];
t.Priority = inputvalues[3];
//t.RecordType = inputvalues[4];
t.Status = inputvalues[4];
t.Type = inputvalues[5];
t.Description = inputvalues[6];
tskstoupload.add(t);
}