Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in Java by (13.1k points)
Can anyone help me with the date format which are available for SimpleDateFormat class in Java?

1 Answer

0 votes
by (26.7k points)

Basically, there are many numbers of date formats are available like dd/MM/yyyy or YYYY-'W'ww-u. So, you can also create by mixing the letters. Given below is the pattern letters:

G - Era designator (AD)

y - Year (1996; 96)

Y - Week Year (2009; 09)

M - Month in year (July; Jul; 07)

w - Week in year (27)

W - Week in month (2)

D - Day in year (189)

d - Day in month (10)

F - Day of week in month (2)

E - Day name in week (Tuesday; Tue)

u - Day number of week (1 = Monday, ..., 7 = Sunday)

a - AM/PM marker

H - Hour in day (0-23)

k - Hour in day (1-24)

K - Hour in am/pm (0-11)

h - Hour in am/pm (1-12)

Also, to use simple date format you can use like:

new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss.SSSZ");

I hope this will help.

Want to become a Java Expert? join Java Training now!!

Want to know more about Java? Watch this video on Java Tutorial for Beginners | Java Programming:

Related questions

0 votes
1 answer
asked Oct 9, 2020 in BI by dev_sk2311 (45k points)
0 votes
1 answer
0 votes
2 answers
asked Feb 19, 2021 in Java by Harsh (1.5k points)

Browse Categories

...