Skip to content

Instantly share code, notes, and snippets.

@DaChelimo
Last active November 11, 2020 10:33
Show Gist options
  • Save DaChelimo/26b56d643e87176c5b04860f9d593a46 to your computer and use it in GitHub Desktop.
Save DaChelimo/26b56d643e87176c5b04860f9d593a46 to your computer and use it in GitHub Desktop.
Patterns for SimpleDateFormat for Java & Kotlin
### SimpleDateFormat Patterns
*Year*
// yyyy or YYYY - Year
*Month*
MM - Month of the year (eg. 11)
MMM - Month of the year (eg. Nov)
MMMM - Month of the year (eg. November)
*Day*
EE- Day of the week (eg. Wed)
EEEE - Day of the week (eg. Wednesday)
dd - Day of the Month (eg. 11)
DD - Day of the year (eg. 316)
*Hour*
hh - Hour
mm - Minute
ss - Seconds
SSS - MilliSeconds
**Full example**
SimpleDateFormat("dd/MM/yyyy (DD) hh:mm:ss").format(Date()) prints 11/11/2020 (316) 09:26:22:476
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment