Hey guys. I've got a small bit of code i'm having trouble with. Here's the idea. The user has a JTextField to put a date into. Once they put in the date, it is
1) Checked to make sure it is actually a date
2) Converted into type gregordianCalendar
3) Stored in an ArrayList for the future part of the program
I'm having trouble converting from GregordianCalendar to Array List. Any Help?
Don't return the transactions List from the transactions method. Return an unmodifiable copy, with this method. That way, nobody can get their hands on the transactions list and change the transactions. And change the declared type of the List (and return type for that method) to List<Transaction>. I also think you should make all the fields in the Transaction class final, again so nobody can change them. Your Transaction class will then need a constructor. Since GregorianCalendar is mutable, you would have to return a copy of the date from any getDate() method in the Transaction class. Again, to prevent anybody changing the details of the transaction.
Why have you got a return; statement in the catch block? You wold be better putting the reading part in a loop, so it will try again until a date is entered in the correct format.
You cannot change a Calendar object to a List. What you can do it set it as the field in the new Transaction object, and add that Transaction to the List.