Java Date format

Here we will learn how to convert a date string into date object. Java Date format can be used here.

Simple Date Format Option

Example : 24 July2012 4:00:23 PM

Note*:: Take special care of small and caps letter.

Letter Component Examples Value
G Era designator (AD/BC) AD
y Year 2012 or 12
Y Week year 2012; 12
M Month in year July; Jul; 07
w Week in year 27
W Week in month 4
D Day in year 189
d Day in month 24
F Day of week in month 2
E Day name in week Tuesday; Tue
u Day number of week (1 = Monday, …, 7 = Sunday) 2
a Am/pm marker(AM/PM) PM
H Hour in day (0-23) 16
k Hour in day (1-24) 17
K Hour in am/pm (0-11) 4
h Hour in am/pm (1-12) 12
m Minute in hour 30
s Second in minute 55
S Millisecond 978
z Time zone Pacific Standard Time; PST; GMT-08:00
Z Time zone -0800
X Time zone -08; -0800; -08:00

Out put will be

1 Comment Java Date format

  1. Anju Sinha

    I am a beginner for string and i know only core java,I find difficulty in understanding this..plz help me

    Reply

Leave A Comment

Your email address will not be published. Required fields are marked *