Skip to content

Instantly share code, notes, and snippets.

@johwanghee
Last active September 19, 2017 09:32
Show Gist options
  • Save johwanghee/a5ad139fd26978b6494284f6cc23dd2d to your computer and use it in GitHub Desktop.
Save johwanghee/a5ad139fd26978b6494284f6cc23dd2d to your computer and use it in GitHub Desktop.
change current time to string(java, go)
/* Java */
Calendar cal = Calendar.getInstance();
SimpleDateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
System.out.println(fmt.format(cal.getTime()));
// Output "2017-02-28 11:35:01"
/* Go */
time.Now().format("2006-01-02 15:04:05")
// Output "2017-02-28 11:35:01"
/* Python */
from datetime import datetime
datetime.now().strftime('%Y-%m-%d %H:%M:%S.%f')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment