Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@ebouchut
Last active October 6, 2019 14:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save ebouchut/415ff16aa327735ab846 to your computer and use it in GitHub Desktop.
Save ebouchut/415ff16aa327735ab846 to your computer and use it in GitHub Desktop.
Format a Java Date as UTC String: yyyy-mm-dd HH:mm:ss'Z'
publicString formatDateAsUTC(Date date) {
Calendar calendar = Calendar.getInstance();
calendar.setTime(date);
SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss'Z'");
sdf.setTimeZone(TimeZone.getTimeZone("UTC"));
return sdf.format(date);
}
@sckirk
Copy link

sckirk commented Oct 3, 2019

ebouchut: are you able to merge in the fork that I created? There is a typo in this gist, my fork corrects it.
In case other people reference this useful code in the future, I wanted to update it for them. :)

@ebouchut
Copy link
Author

ebouchut commented Oct 6, 2019

Hey @sckirk

Good catch.
I updated the gist.
Thank you.

@sckirk
Copy link

sckirk commented Oct 6, 2019 via email

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment