java.util.Date
, like a lot of other classes in the JDK, overrides toString()
, which allows you to control the string representation of your objects.
You can, of course, do this for your own classes too.
1
solved How new Java.util.Date() works while other classes return just reference?