Skip to content

Instantly share code, notes, and snippets.

@fnzainal
Last active September 29, 2017 02:26
Show Gist options
  • Save fnzainal/cd09ba9fe407b3315fe9fbfe35e26a1c to your computer and use it in GitHub Desktop.
Save fnzainal/cd09ba9fe407b3315fe9fbfe35e26a1c to your computer and use it in GitHub Desktop.
formating date time on android
DateFormat df = new SimpleDateFormat("EEE, d MMM yyyy, HH:mm");
String date = df.format(Calendar.getInstance().getTime());

Format ---- output

"yyyy.MM.dd G 'at' HH:mm:ss z" ---- 2001.07.04 AD at 12:08:56 PDT
"hh 'o''clock' a, zzzz" ----------- 12 o'clock PM, Pacific Daylight Time
"EEE, d MMM yyyy HH:mm:ss Z"------- Wed, 4 Jul 2001 12:08:56 -0700
"yyyy-MM-dd'T'HH:mm:ss.SSSZ"------- 2001-07-04T12:08:56.235-0700
"yyMMddHHmmssZ"-------------------- 010704120856-0700
"K:mm a, z" ----------------------- 0:08 PM, PDT
"h:mm a" -------------------------- 12:08 PM
"EEE, MMM d, ''yy" ---------------- Wed, Jul 4, '01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment