Logging with date in Java
Elegant and efficient are different things.

SimpleDateFormat instances are not thread safe. It is common in my code to have a few utility classes, and one method I often have on the utility class is:

private static final ThreadLocal&lt;SimpleDateFormat&gt; localDateFormat = new ThreadLocal&lt;SimpleDateFormat&gt;() {

    @Override
    protected SimpleDateFormat initialValue() {
             return new SimpleDateFormat(....);
    }

};

public static SimpleDateFormat getDateFormatter() {
    return localDateFormat.get();
}


That way, anyone calling getDateFormatter() gets an instance of the standard formatter for my system, and it is local to the current thread. I don't let them 'hang around', so you can't assign them to class fields, etc.

The benefit is that there's at most one instance per thread, it is thread safe (if you don't do silly things with it), and it is neat:

public void log(String message) {
    logTextArea.append(String.format("%s : %s%n",
           Utils.getDateFormat().format(new Date()), message));
}


Unfortunately, I don't think you have taken this far enough. You need another utility method like:

public static String formatLogMessage(String message) {
    return String.format("%s : %s%n",
           Utils.getDateFormat().format(new Date()), message);
}


and then all your various places that modify things like this can reuse the code:

public void log(String message) {
    logTextArea.append(Utils.formatLogMesssage(message));
}


Update: I somewhat misread your specific question, and in response to your comment:


creating a new short-term new Date() is not perfect, but is still very fast (it will be cycled out by the garbage collector very quickly, and not impact that very much at all). There are perhaps better ways though...
I don't use the commons library, so was not aware that the FastDateFormat class was thread-safe (it probably does what I suggest above), but, at the same time, the extra log-method is a good idea because it brings all the different log places in to one spot so you can change formats, etc. with just one changed line of code.


Additionally, if you are concerned about the actual performance of the new Date(), (and if you actually read the full Javadoc of the FastDateFormat class you sent me... ;-) you can replace that one method:


public static String formatLogMessage(String message) {
    return String.format("%s : %s%n",
           Utils.getDateFormat().format(new Date()), message);
}



with:

public static String formatLogMessage(String message) {
    return String.format("%s : %s%n",
           DateFormatUtils.ISO_TIME_NO_T_FORMAT.format(System.currentTimeMillis()), message);
}