While the answer by PopoFibo is correct, clever, and specifically answers the question, the larger answer is: Use a logging framework. A logging framework will automatically insert the current date-time and do much more as well.
Usually we use System.out.println() just for quick-and-dirty checking of values while programming. The more organized way to approach getting information out of your program is using a logging framework (or JMX – Java Management Extensions, but that’s another topic altogether).
log4j
In the old days, the log4j framework was a popular framework, and one of the first to create a slick logging system. Currently an overhaul of log4j is underway, called Apache Log4j 2.
java.util.logging
Later, Sun added a logging facility to Java. While useful, many folks consider it less-than-optimal.
SLF4J
The creator of log4j later went on to create a successor to his previous invention. He broke it apart into (1) a façade, an interface-based API, and (2) any number of implementations that actually do the logging. The idea is that you could plugin or replace various implementations without changing your own code base.
The façade is called SLF4J (Simple Logging Façade for Java). SLF4J comes bundled with a couple very simple implementations. But generally you will want to plugin more robust, flexible, or specialized implementations.
Several adapters are available to use other logging frameworks that may not be aware of SLF4J such as log4j or java.util.Logging.
Many libraries use SLF4J for their internal logging so that anyone using that library can plug in their own particular choice of logging framework underneath.
LogBack
The creator of SLF4J also created his own full implementation of SLF4J, called LogBack.
Uses
One of the main points to using these logging frameworks is flexibility. You can configure them to send messages to System.out
, System.err
, text files, databases, and other destinations.