i write a small apex code snippet.

if(v.dataType == 'Date')
    {  System.debug('date is'+mapField.get(field1.name));
        System.debug('field is'+field1);
        String str = mapField.get(field1.name).fieldValue;
        Date x;
        if(str ==null)
        x= Date.newInstance(str.split('\\')[2],str.split('\\')[0],str.split('\\')[1]);

        if(Date.valueOf(dataType1) == x)
         else conditionsResult.add(false);

on line x= Date.newInstance(str.split('\\')[2],str.split('\\')[0],str.split('\\')[1]); its giving me error

Variable does not exist: Date

but date is a global object i think.please help how to remove this error ??


Date.newInstance does not accept strings, it accepts integers according to the documentation. You are passing in Strings.

You could possibly try the Date.parse method.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.