> 2
> 3 import java.text.DateFormatSymbols;
> 4
> 5 public class DateUtil {
> 6 private static DateFormatSymbols dateFormatSymbols = new DateFormatSymbols();
> 7
> 8 public static String[] getMonthNames() {
> 9 return dateFormatSymbols.getMonths();
> 10 }
> 11
> 12 public static boolean isLeapYear(int year) {
> 13 boolean fourth = year % 4 == 0;
> 14 boolean hundredth = year % 100 == 0;
> 15 boolean fourHundredth = year % 400 == 0;
> 16 return fourth && (!hundredth || fourHundredth);
> 17 }
> 18
> 19 public static int lastDayOfMonth(Month month, int year) {
> 20 if (month == Month.FEBRUARY && isLeapYear(year))
> 21 return month.lastDay() + 1;
> 22 else
> 23 return month.lastDay();
> 24 }
> 25
> 26 public static int leapYearCount(int year) {
> 27 int leap4 = (year - 1896) / 4;
> 28 int leap100 = (year - 1800) / 100;
> 29 int leap400 = (year - 1600) / 400;
> 30 return leap4 - leap100 + leap400;
> 31 }
> 32 }
Листинг Б.14. DayDateFactory.java (окончательная версия)
> 1 package org.jfree.date;
> 2
> 3 public abstract class DayDateFactory {
> 4 private static DayDateFactory factory = new SpreadsheetDateFactory();
> 5 public static void setInstance(DayDateFactory factory) {
> 6 DayDateFactory.factory = factory;
> 7 }
> 8
> 9 protected abstract DayDate _makeDate(int ordinal);
> 10 protected abstract DayDate _makeDate(int day, Month month, int year);
> 11 protected abstract DayDate _makeDate(int day, int month, int year);
> 12 protected abstract DayDate _makeDate(java.util.Date date);
> 13 protected abstract int _getMinimumYear();
> 14 protected abstract int _getMaximumYear();
> 15
> 16 public static DayDate makeDate(int ordinal) {
> 17 return factory._makeDate(ordinal);
> 18 }
> 19
> 20 public static DayDate makeDate(int day, Month month, int year) {
> 21 return factory._makeDate(day, month, year);
> 22 }
> 23
> 24 public static DayDate makeDate(int day, int month, int year) {
> 25 return factory._makeDate(day, month, year);
> 26 }
> 27
> 28 public static DayDate makeDate(java.util.Date date) {
Листинг Б.14 (продолжение)
> 29 return factory._makeDate(date);
> 30 }
> 31
> 32 public static int getMinimumYear() {
> 33 return factory._getMinimumYear();
> 34 }
> 35
> 36 public static int getMaximumYear() {
> 37 return factory._getMaximumYear();
> 38 }
> 39 }
Листинг Б.15. SpreadsheetDateFactory.java (окончательная версия)
> 1 package org.jfree.date;
> 2
> 3 import java.util.*;
> 4