I have a date as string as below I am using the below code I am getting the below Exception when excuting this code: Can someone help me what I am doing wrong here? Answer You should pass 01/31/2020or update the format to M/dd/yyyy DateTimeFormatter documentation The month is considered as a number and in the documentation : Number: If