i want to pass date into newInstance method of datetime class then i will get date of week.when i have given static date it's working fine but when i try to pass dynamically i am getting error please share you ideas.
Working Part:
Datetime dt = DateTime.newInstance(2018, 9, 20); String dayOfWeek=dt.format('EEEE'); System.debug('Day : ' + dayOfWeek);
Datetime dt = DateTime.newInstance(2018, 9, 20);
String dayOfWeek=dt.format('EEEE');
System.debug('Day : ' + dayOfWeek);
Not working Part:
i am getting dates from external system so i can't assign statically here i am facing problem
String s1 = '2018-09-21'; String target = '-'; String replacement = ','; String s2 = s1.replace(target, replacement); Datetime dt = DateTime.newInstance(s2); String dayOfWeek=dt.format('EEEE'); System.debug('Day : ' + dayOfWeek);
String s1 = '2018-09-21';
String target = '-';
String replacement = ',';
String s2 = s1.replace(target, replacement);
Datetime dt = DateTime.newInstance(s2);
String dayOfWeek=dt.format('EEEE');
System.debug('Day : ' + dayOfWeek);