I need in my wrapper class the activity date from the task object as string to display at a visual force page. My two version below does n't work.
If I use this version I get an error (Attempt to de-reference a null object).
public class Wrapper implements Comparable {
private final Id id;
private final DateTime createDateSort;
private final String createDate;
public wrapper(Task t) {
id = t.Id;
DateTime activitydate = t.ActivityDate;
createDate = activitydate.format('dd.MM.yy', UserInfo.getTimeZone().toString());
createDateSort = t.ActivityDate;
}
And if I use this version I get the error (Method does not exist or incorrect signature: void format(String) from the type Date
public class Wrapper implements Comparable {
private final Id id;
private final DateTime createDateSort;
private final String createDate;
public wrapper(Task t) {
id = t.Id;
createDate = t.activitydate.format('dd.MM.yy');
createDateSort = t.ActivityDate;
}