— Scott McNealy, Sun Microsystems Chairman, President and ceo


%tc ”, new Date()); Sun Nov 28 14:52:41 MST 2004



Download 40,57 Mb.
Pdf ko'rish
bet286/555
Sana26.05.2022
Hajmi40,57 Mb.
#609235
1   ...   282   283   284   285   286   287   288   289   ...   555
Bog'liq
Head First Java (Kathy Sierra, Bert Bates) (z-lib.org)

%tc
”, new Date());
Sun Nov 28 14:52:41 MST 2004
The complete date and time 
%t
c
String.format(“
%tr
”, new Date());
03:01:47 PM
Just the time 
%t
r
Date today = new Date();
String.format(“
%tA, %tB %td
”,today,today,today);
Sunday, November 28
Day of the week, month and day
%t
A
%t
B
%t
d
Date today = new Date();
String.format(“%tA, %
<
tB %
<
td”,today);
Same as above, but 
without duplicating the arguments
%t
A
%t
B
%t
d
There isn’t a single format specifier that will do exactly what we 
want, so we have to combine three of them for day of the week 
(%tA), month (%tB), and day of the month (%td).
But that means we have to 
pass the Date object in three 
times, one for each part of the 
format that we want. In other 
words, the %tA will give us just 
the day of the week, but then 
we have to do it again to get 
just the month and again for the 
day.of the month.
The comma is not part of the formatting... it’s 
just the character we want printed after the 
first inserted formatted argument.
The angle-bracket “<” is just another 
flag in the specifier that tells the 
formatter to “use the previous argument 
again.” So it saves you from repeating the 
arguments, and instead you format the 
same argument three different ways.
You can think of this as kind of like calling three 
different getter methods on the Date object, to 
get three different pieces of data from it.


302
 
chapter 10
Working with Dates
You need to do more with dates than just get 
today’s date. You need your programs to adjust 
dates, find elapsed times, prioritize schedules, 
heck, make schedules. You need industrial 
strength date manipulation capabilities. 
You could make your own date routines of 
course... (and don’t forget about leap years!) 
And, ouch, those occasional, pesky leap-
seconds. Wow, this could get complicated. The 
good news is that the Java API is rich with 
classes that can help you manipulate dates. 
Sometimes it feels a little too rich...
Let’s see... how many work 
days will there be if the 
project starts on Feb 27th and 
ends on August 5th?

Download 40,57 Mb.

Do'stlaringiz bilan baham:
1   ...   282   283   284   285   286   287   288   289   ...   555




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©hozir.org 2024
ma'muriyatiga murojaat qiling

kiriting | ro'yxatdan o'tish
    Bosh sahifa
юртда тантана
Боғда битган
Бугун юртда
Эшитганлар жилманглар
Эшитмадим деманглар
битган бодомлар
Yangiariq tumani
qitish marakazi
Raqamli texnologiyalar
ilishida muhokamadan
tasdiqqa tavsiya
tavsiya etilgan
iqtisodiyot kafedrasi
steiermarkischen landesregierung
asarlaringizni yuboring
o'zingizning asarlaringizni
Iltimos faqat
faqat o'zingizning
steierm rkischen
landesregierung fachabteilung
rkischen landesregierung
hamshira loyihasi
loyihasi mavsum
faolyatining oqibatlari
asosiy adabiyotlar
fakulteti ahborot
ahborot havfsizligi
havfsizligi kafedrasi
fanidan bo’yicha
fakulteti iqtisodiyot
boshqaruv fakulteti
chiqarishda boshqaruv
ishlab chiqarishda
iqtisodiyot fakultet
multiservis tarmoqlari
fanidan asosiy
Uzbek fanidan
mavzulari potok
asosidagi multiservis
'aliyyil a'ziym
billahil 'aliyyil
illaa billahil
quvvata illaa
falah' deganida
Kompyuter savodxonligi
bo’yicha mustaqil
'alal falah'
Hayya 'alal
'alas soloh
Hayya 'alas
mavsum boyicha


yuklab olish