List of Java Simple Date Formats (Cheatsheet)


Cheatsheet Java Simple Date Format List

SimpleDateFormat is a class that was added to java.text package that can be used for formatting and parsing dates in a locale-sensitive way. Using this Class you can convert Date to String or String to Date.

In this article, we will list the most important String patterns that you should have handy and can use as a cheatsheet while doing Date formatting and parsing,

List of Java Simple Date Formats (Cheatsheet):

Sr.No Represents Date & Time Format Example Date Result
1 date (0-31) d Aug 02 11:27:45 GMT 2022 2
2 date (0-31) d Aug 18 11:27:45 GMT 2022 18
3 date (00-31) dd Aug 02 11:27:45 GMT 2022 02
4 date (00-31) dd Aug 18 11:27:45 GMT 2022 18
5 month (1-12) M Aug 02 11:27:45 GMT 2022 08
6 month (1-12) M Dec 02 11:27:45 GMT 2022 12
7 month (01-12) MM Aug 02 11:27:45 GMT 2022 02
8 month (01-12) MM Dec 02 11:27:45 GMT 2022 12
9 month MMM Dec 02 11:27:45 GMT 2022 Dec
10 month MMMM Dec 02 11:27:45 GMT 2022 December
11 year y Dec 02 11:27:45 GMT 2001 2001
12 year y Dec 02 11:27:45 GMT 2022 2022
13 year yy Dec 02 11:27:45 GMT 2001 01
14 year yy Dec 02 11:27:45 GMT 2022 22
15 year yy Dec 02 11:27:45 GMT 1990 90
16 year yy Dec 02 11:27:45 GMT 1890 90
17 year yyy Dec 02 11:27:45 GMT 2001 2001
18 year yyy Dec 02 11:27:45 GMT 2022 2022
19 year yyy Dec 02 11:27:45 GMT 1990 1990
20 year yyy Dec 02 11:27:45 GMT 1890 1890
21 year yyyy Dec 02 11:27:45 GMT 2022 2022
22 date & month d-M Jan 01 11:27:45 GMT 2022 1-1
23 date & month dd-M Jan 01 11:27:45 GMT 2022 01-1
24 date & month dd-MM Jan 13 11:27:45 GMT 2022 13-01
25 month & date MM-dd Dec 02 11:27:45 GMT 2022 01-13
26 month & year M-yy Jan 01 11:27:45 GMT 2022 1-22
27 month & year MM-yy Jan 13 11:27:45 GMT 2022 01-22
28 month & year MM-yyyy Jan 13 11:27:45 GMT 2022 01-2022
29 year & month yy-M Jan 13 11:27:45 GMT 2022 22-1
30 year & month yy-MM Jan 13 11:27:45 GMT 2022 22-01
31 year & month yyyy-MM Jan 13 11:27:45 GMT 2022 2022-01
32 date, month & year d-M-y Jan 01 11:27:45 GMT 2022 1-1-2022
33 date, month & year dd-MM-yy Jan 13 11:27:45 GMT 2022 13-01-22
34 date, month & year dd-MM-yyyy Jan 13 11:27:45 GMT 2022 13-01-2022
35 month,day & year MM-dd-yy Jan 13 11:27:45 GMT 2022 01-13-22
36 month,day & year MM-dd-yyyy Jan 13 11:27:45 GMT 2022 01-13-2022
37 year,month & date yyyy-MM-dd Jan 13 11:27:45 GMT 2022 2022-01-13
38 week of year (1-53) w Jan 01 05:30:00 GMT 2022 1
39 week of year (01-53) ww May 01 05:30:00 GMT 2022 01
40 week of year (0-99) w May 01 05:30:00 GMT 2022 19
41 week of year (00-99) ww May 01 05:30:00 GMT 2022 19
42 week of month (1-12) W May 14 05:30:00 GMT 2022 2
43 week of month (01-12) WW May 14 05:30:00 GMT 2022 02
44 day of week of month F May 14 05:30:00 GMT 2022 2
45 day of week of month FF May 14 05:30:00 GMT 2022 02
46 day name E May 14 05:30:00 GMT 2022 Sat
47 day name EEE May 14 05:30:00 GMT 2022 Sat
48 day name EEEE May 14 05:30:00 GMT 2022 Saturday
49 day as number (1-7) u May 14 05:30:00 GMT 2022 3
50 day as number (01-07) uu May 14 05:30:00 GMT 2022 03
51 hour of day (0-23) H May 14 05:30:00 GMT 2022 5
52 hour of day (00-23) HH May 14 05:30:00 GMT 2022 05
53 hour of day (0-23) H May 14 13:30:00 GMT 2022 13
54 hour of day (00-23) HH May 14 23:30:00 GMT 2022 23
55 hour of day (1-24) k May 14 00:30:00 GMT 2022 24
56 hour of day (1-24) k May 14 05:30:00 GMT 2022 5
57 hour of day (1-24) k May 14 23:30:00 GMT 2022 23
58 hour of day (1-24) kk May 14 00:30:00 GMT 2022 24
59 hour of day (1-24) kk May 14 05:30:00 GMT 2022 05
60 hour of day (1-24) kk May 14 17:30:00 GMT 2022 17
61 hour of day am/pm (0-11) K May 14 05:30:00 GMT 2022 5
62 hour of day am/pm (0-11) K May 14 15:30:00 GMT 2022 3
63 hour of day am/pm (0-11) K May 14 23:30:00 GMT 2022 11
64 hour of day am/pm (0-11) KK May 14 05:30:00 GMT 2022 05
65 hour of day am/pm (0-11) KK May 14 15:30:00 GMT 2022 03
66 hour of day am/pm (0-11) KK May 14 23:30:00 GMT 2022 11
67 hour of day am/pm (1-12) h May 14 00:30:00 GMT 2022 12
68 hour of day am/pm (1-12) h May 14 15:30:00 GMT 2022 3
69 hour of day am/pm (1-12) h May 14 23:30:00 GMT 2022 11
70 hour of day am/pm (1-12) hh May 14 15:30:00 GMT 2022 03
71 minute of hour (0-59) m May 14 15:01:00 GMT 2022 1
72 minute of hour (0-59) m May 14 15:30:00 GMT 2022 30
73 minute of hour (00-59) mm May 14 15:00:00 GMT 2022 00
74 minute of hour (00-59) mm May 14 15:09:00 GMT 2022 09
75 minute of hour (00-59) mm May 14 15:45:00 GMT 2022 45
76 second in minute (00-59) s May 14 15:45:00 GMT 2022 0
77 second in minute (00-59) s May 14 15:45:07 GMT 2022 7
78 second in minute (00-59) ss May 14 15:45:07 GMT 2022 07
79 second in minute (00-59) ss May 14 15:45:00 GMT 2022 00
80 millisecond (000-999) S May 14 15:45:21 GMT 2022 692
81 am/pm a May 14 15:45:21 GMT 2022 PM
82 am/pm a May 14 09:45:21 GMT 2022 AM
83 era (AD/BC) G May 14 09:45:21 GMT 2022 AD
84 time zone z May 14 09:45:21 GMT 2022 GMT
85 time zone z May 14 01:24:21 CDT 2022 CDT
86 time zone Z May 14 01:24:21 CDT 2022 -0500
87 time zone X May 14 01:24:21 CDT 2022 -05
88 time zone XX May 14 01:24:21 CDT 2022 -0500

Java Date Formats

Sr.No Date & Time Pattern Example
1 yyyy 2022
2 yyyy-MM 2022-08
3 dd-MM-yyyy 23-08-2022
4 MM-dd-yyyy 08-23-2022
5 M-d-yyyy 8-23-2022
6 dd-MM-yy 23-08-22
7 yyyy.MM.dd G 'at' HH:mm:ss z 2022.08.23 AD at 11:12:15 CDT
8 EEE, MMM d, ''yy Wed, Jul 4, '01
9 h:mm a 11:07 PM
10 yyyy-MM-dd'T'HH:mm:ss.SSSZ 2022-08-22T11:12:26.213-0500
11 yyyy-MM-dd'T'HH:mm:ss.SSSXXX 2022-08-22T11:12:26.213-05:00
12 YYYY-'W'ww-u 2001-W27-3
13 dd/MM/yyyy 22/08/2022
14 MM/dd/yyyy 08/22/2022
15 ddMMyyyy 23082022
Advertisements
Try Out Code2care Dev Tools:

Advertisements

Advertisements
Code2care is an initiative to publish and share varied knowledge in programming and technical areas gathered during day-to-day learnings and development activities.

Students and software developers can leverage this portal to find solutions to their various queries without re-inventing the wheel by referring to our easy to understand posts. Technical posts might include learnings, tutorials, trouble-shooting steps, video tutorials, code snippets, how-to, blogs, articles, etc.

🎉 We are celebrating the 10th years of Code2care! Thank you for all your support!

We strongly support Gender Equality & Diversity.


echo('');