String str = null;
Date d = Date.valueOf(str);
I am getting the following error when running the above snippet in Anon Apex.
Line: 2, Column: 1
System.NullPointerException: Argument cannot be null.
Resolution: Using Ternary Operator we can fix the null check
Date d = String.isBlank(str) ? null : Date.valueOf(str);
No comments:
Post a Comment