Skip to Content
Java™ Phrasebook
book

Java™ Phrasebook

by Timothy Fisher
November 2006
Intermediate to advanced
224 pages
3h 29m
English
Sams
Content preview from Java™ Phrasebook

Finding the Day of Week/Month/Year or Week Number

Calendar cal = Calendar.getInstance();
											System.out.println("Day of week: " +
											cal.get(Calendar.DAY_OF_WEEK));
											System.out.println("Month: " +
											cal.get(Calendar.MONTH));
											System.out.println("Year: " +
											cal.get(Calendar.YEAR));
											System.out.println("Week number: " +
											cal.get(Calendar.WEEK_OF_YEAR));

You can easily determine values such as the day of the week, the month, the year, the week number, and more using the Calendar object’s get() method. In this phrase, we get a Calendar object representing the current date and time using the getInstance() method. We then print out the day of the week, the month, the year, and the week of the year by using the get() method and passing the appropriate Calendar constant ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Ruby Phrasebook

Ruby Phrasebook

Jason Clinton
Wicked Cool Java

Wicked Cool Java

Brian D. Eubanks
Just Java™ 2

Just Java™ 2

Peter van der Linden
What Employees Want Most in Uncertain Times

What Employees Want Most in Uncertain Times

Kristine W. Powers, Jessica B.B. Diaz

Publisher Resources

ISBN: 0768668255Purchase book