Last active
September 19, 2017 09:32
-
-
Save johwanghee/a5ad139fd26978b6494284f6cc23dd2d to your computer and use it in GitHub Desktop.
change current time to string(java, go)
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
/* 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