Unable to tackle module 2 of Qmoney with invaliddate and invalidstocks continuously popping

I have wrote many try catch. I have tried to parse the daate and validate it but nothing is giving me the correct answer. I am unable to catch the runtime error exception as it is never getting thrown. I donot understand the reason why it is not getting thrown. Secondly ,
SimpleDateFormat.parser is also parsing dates like 2019-29-3a where it should i have thrown an exception since i have put that in a try block and catch is catching any exception thrown . Rather it throws invalid date for 2019-29-a3. I haveno clue how to go about.

Check if there is some hardcode values or not. If not then check if end date is not provided then you are extracting the data for latest date.

You dont need try catch block. The dates are in 2 format .
One in LocalDate
And other in String.
You need to parse the string into LocalDate and then compare if end date is less than any of the purchase date. If it is, then throw runtime exception

Take a look at this link to get idea about throwing exceptions.


i am also facing same issue

Unable to understand what to do…
please guide me in the right direction.

Make sure you didn’t hard code anything.

Hi @sudhanshu,

Check these files

  1. ModuleTwoTest.java - find out how the failed tests are implemented in this class
  2. trades_invalid_stock.json & trades_invalid_dates.json - compare the respective tests w/ the contents of these files

Ask yourselves, are there any possibilites of any errors or exceptions that may occur due to these tests. If so, how should I resolve those? Should I return some null value or throw an error or something else?

Hint: You can see the assert statement in the test methods to know how to deal with the errors/exceptions, if occuring

1 Like

Thank you all for your humble support.