Sonar - Make DATE_FORMAT as instance variable

Use joda-time or simply replace variable with method:

public static final DateFormat getDateTimeFormat() {
    return new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss:SSS");
}

Static variable are mostly used for Constants.
Here you have declared static and assigning it instance of SimpleDateFormat.
Either make DATE_TIME_FORMAT non-static or assign a constant to this variable.

Better change it to instance variable and use a Sting to do that.
e.g public final String DATE_FORMAT = "yyyy-MM-dd'T'HH:mm:ss:SSS";


The triggered rule is S2885:

Non-thread-safe fields should not be static

squid:S2885

Not all classes in the standard Java library were written to be thread-safe. Using them in a multi-threaded manner is highly likely to cause data problems or exceptions at runtime. This rule raises an issue when an instance of Calendar, DateFormat, javax.xml.xpath.XPath, or javax.xml.validation.SchemaFactory is marked static.

Since SimpleDateFormat is not thread safe, it doesn't work well with being shared between threads. You might well end up with wrong formatting of dates.

If you are using Java 8 or above you should use DateTimeFormatter, as in this answer. Otherwise, using Joda Time makes sence, as per this answer.


As a side note, having a class named Constants end let it contain all sorts of static final variables rarely makes sense. Typically you should put each constant where it belongs.