Skip to content

Instantly share code, notes, and snippets.

@vxhviet
Last active March 30, 2016 03:57
Show Gist options
  • Save vxhviet/2e7ae9b57419d9e48cad083202cfe5f3 to your computer and use it in GitHub Desktop.
Save vxhviet/2e7ae9b57419d9e48cad083202cfe5f3 to your computer and use it in GitHub Desktop.
Current timestamp as filename in Java, Android

Source: StackOverflow

Question: How do I name the new files created with the current timestamp?

Answer:

String fileName = new SimpleDateFormat("yyyyMMddhhmm'.txt'").format(new Date());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment