Java The Complete Reference, Seventh Edition

(Greg DeLong) #1

Chapter 27: NIO, Regular Expressions, and Other Packages 843


System.out.println(sdf.format(date));
}
}


Sample output from this program is shown here:


10:25:03
12 Jul 2006 10:25:03 CDT
Wed Jul 12 2006

Symbol Description
a AMorPM
d Day of month (1–31)
h Hour inAM/PM(1–12)
k Hour in day (1–24)
m Minute in hour (0–59)
s Second in minute (0–59)
w Week of year (1–52)
y Year
z Time zone
D Day of year (1–366)
E Day of week (for example, Thursday)
F Day of week in month
G Era (that is, AD or BC)
H Hour in day (0–23)
K Hour inAM/PM(0–11)
M Month
S Millisecond in second
W Week of month (1–5)
Z Time zone in RFC822 format

TABLE 27-6

Formatting String
Symbols for
SimpleDateFormat

Free download pdf