001package edu.pdx.cs410J.datesAndText; 002 003import java.util.*; 004 005/** 006 * Prints out information about today's date. Demonstrates the 007 * <code>Date</code> and <code>Calendar</code> classes. 008 */ 009public class Today { 010 011 public static void main(String[] args) { 012 Date today = new Date(); 013 Calendar cal = Calendar.getInstance(); 014 cal.setTime(today); 015 016 int dayOfWeek = cal.get(Calendar.DAY_OF_WEEK); 017 int dayOfYear = cal.get(Calendar.DAY_OF_YEAR); 018 int weekOfMonth = cal.get(Calendar.WEEK_OF_MONTH); 019 020 StringBuffer sb = new StringBuffer(); 021 sb.append("Today is " + today + "\n"); 022 sb.append("It's been " + today.getTime() + 023 "ms since the epoch."); 024 sb.append("\nIt is the " + dayOfWeek + 025 "th day of the week \nand the " + 026 dayOfYear + "th day of the year. "); 027 sb.append("\nWe are in the " + weekOfMonth + 028 "th week of the month."); 029 System.out.println(sb.toString()); 030 031 } 032 033}