When there are no more live references to it.
The reference d in your main method is pointing to d2 after the method call so d2 will only be eligible after the main method has exited or removed all references to it (e.g if the main method sets d to null)
Remember that variables are not garbage collected. Objects are. So it doesn't make sense to talk about whether d2 is eligible or not. The question is whether the object that d2 referenced is eligible. And that will be, as E Armitage says, when there are no other live references. When getDate() exits you're assigning the return value (a reference to that same object) to the d variable, so it's still live until the program ends.