> 13 SUNDAY(Calendar.SUNDAY);
> 14
> 15 private final int index;
> 16 private static DateFormatSymbols dateSymbols = new DateFormatSymbols();
> 17
> 18 Day(int day) {
> 19 index = day;
> 20 }
> 21
> 22 public static Day fromInt(int index) throws IllegalArgumentException {
> 23 for (Day d : Day.values())
> 24 if (d.index == index)
> 25 return d;
> 26 throw new IllegalArgumentException(
> 27 String.format(«Illegal day index: %d.», index));
> 28 }
> 29
> 30 public static Day parse(String s) throws IllegalArgumentException {
> 31 String[] shortWeekdayNames =
> 32 dateSymbols.getShortWeekdays();
> 33 String[] weekDayNames =
> 34 dateSymbols.getWeekdays();
> 35
> 36 s = s.trim();
> 37 for (Day day : Day.values()) {
> 38 if (s.equalsIgnoreCase(shortWeekdayNames[day.index]) ||
> 39 s.equalsIgnoreCase(weekDayNames[day.index])) {
> 40 return day;
> 41 }
> 42 }
> 43 throw new IllegalArgumentException(
> 44 String.format("%s is not a valid weekday string", s));
> 45 }
> 46
> 47 public String toString() {
> 48 return dateSymbols.getWeekdays()[index];
> 49 }
> 50
> 51 public int toInt() {
> 52 return index;
> 53 }
> 54 }
Листинг Б.10. DateInterval.java (окончательная версия)
> 1 package org.jfree.date;
> 2
> 3 public enum DateInterval {
> 4 OPEN {
> 5 public boolean isIn(int d, int left, int right) {
> 6 return d > left && d < right;
> 7 }
> 8 },
> 9 CLOSED_LEFT {
> 10 public boolean isIn(int d, int left, int right) {
> 11 return d >= left && d < right;
> 12 }
> 13 },
> 14 CLOSED_RIGHT {
> 15 public boolean isIn(int d, int left, int right) {
> 16 return d > left && d <= right;
> 17 }
> 18 },
> 19 CLOSED {
> 20 public boolean isIn(int d, int left, int right) {
> 21 return d >= left && d <= right;
> 22 }
> 23 };
> 24
> 25 public abstract boolean isIn(int d, int left, int right);
> 26 }
Листинг Б.11. WeekInMonth.java (окончательная версия)
> 1 package org.jfree.date;
> 2
> 3 public enum WeekInMonth {
> 4 FIRST(1), SECOND(2), THIRD(3), FOURTH(4), LAST(0);
> 5 private final int index;
> 6
> 7 WeekInMonth(int index) {
> 8 this.index = index;
> 9 }
> 10
> 11 public int toInt() {
> 12 return index;
> 13 }
> 14 }
Листинг Б.12. WeekdayRange.java (окончательная версия)
> 1 package org.jfree.date;
> 2
> 3 public enum WeekdayRange {
> 4 LAST, NEAREST, NEXT
> 5 }
Листинг Б.13. DateUtil.java (окончательная версия)
> 1 package org.jfree.date;