Created
December 28, 2018 09:02
-
-
Save littlebeeper/edb72aaa076893cd6404a726520b2880 to your computer and use it in GitHub Desktop.
Java format date as GMT
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private static String convertToGMT(String epoch) { | |
Date date = new Date(Long.parseLong(epoch)); | |
String GMT_FORMAT = "yyyy-MM-dd HH:mm:ss"; | |
SimpleDateFormat dateFormat = new SimpleDateFormat(GMT_FORMAT); | |
dateFormat.setTimeZone(TimeZone.getTimeZone("GMT")); | |
// Calendar calendar = Calendar.getInstance(); | |
// calendar.setTimeInMillis(entityAttribute.toInstant().toEpochMilli()); | |
// calendar.setTimeZone(TimeZone.getTimeZone(entityAttribute.getZone())); | |
// return calendar; | |
return dateFormat.format(date); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment