I have decided to use a DateTimeFormatter instead of using SimpleDateFormat because I heard SimpleDateFormat is not thread-safe. I have declared DateTimeFormatter inside Constant file as follows.
public static final DateTimeFormatter GENERAL_TZ_FORMATTER = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss z");
and inside my class file my implementation like this.
String value = Constant.GENERAL_TZ_FORMATTER.format(new Date(date.get()));
but seems like this is not correct implementation. Because it says format (java.time.temporal.TemporalAccessor) in DateTimeFormatter cannot be applied to (java.util.Date) and returns some error like this, "java.incompatible.types: java.util.Date cannot be converted to java.time.temporal.TemporalAccessor"
I'm doing background research for this and still struggling to find the best way to resolve it. I like to know your ideas about this and it will help me to find a better solution. Really appreciate your suggestions. Thank you.