Given that SimpleDateFormat not thread safe, I would say the easiest way is to use Joda Time . Then you can create one formatter (calling withZone(DateTimeZones.UTC) to indicate that you want UTC), and you are absent:
private static DateTimeFormatter formatter = DateTimeFormat.forPattern(...) .withZone(DateTimeZone.UTC); ... String result = formatter.print(instant);
This has another advantage that you can use Joda Time elsewhere in your code, which is always good :)
Jon skeet
source share