利用java.util.Data类继承声明MyData类

来源:百度知道 编辑:UC知道 时间:2024/06/25 00:29:15
利用java.util.Data类继承声明MyData类,使MyData类增加以下功能:

增加一天,增加一月,增加一年?
教科书中的习题.

public class CalendarExample {

/**
* Helper utility used to print a String to STDOUT.
* @param s String that will be printed to STDOUT.
*/
private static void prt(String s) {
System.out.println(s);
}

private static void prt() {
System.out.println();
}

/**
* Calendar's getTime() method returns a Date object. This can then be
* passed to println() to print today's date (and time) in the traditional
* (but non-localized) format.
*/
private static void doCalendarTimeExample() {
prt("CURRENT DATE/TIME");
prt("=================================================================");
Date now = Calendar.getInstance().getTime();
prt(" Calendar.getInstance().getTime() : " + now);
prt();
}

/**