|
@@ -7,7 +7,7 @@ |
7 |
7 |
|
{ |
8 |
8 |
|
private static final long serialVersionUID = 1L; |
9 |
9 |
|
|
10 |
|
- |
private final int mDay; |
|
10 |
+ |
private /* final */ int mDay; |
11 |
11 |
|
|
12 |
12 |
|
protected AbstractCalendarYMD( int pYear, int pMonth, int pDay ) |
13 |
13 |
|
{ |
|
@@ -22,33 +22,43 @@ |
22 |
22 |
|
} |
23 |
23 |
|
|
24 |
24 |
|
/** |
25 |
|
- |
* Return a T with the Day set to the parameter, this is accomplished by utilizing addDays or minusDays as is appropriate (with their day |
26 |
|
- |
* adjusting logic if appropriate). |
|
25 |
+ |
* Return a T with the Day set to the parameter. |
27 |
26 |
|
*/ |
28 |
27 |
|
public final T day( int pDay ) |
29 |
28 |
|
{ |
30 |
29 |
|
validate( getYear(), getMonth(), pDay ); |
31 |
|
- |
return (mDay == pDay) ? us() : (pDay > mDay) ? LLsetDay( pDay, true ) : LLsetDay( pDay, false ); |
|
30 |
+ |
return (mDay == pDay) ? us() : LLsetDay( pDay ); |
32 |
31 |
|
} |
33 |
32 |
|
|
34 |
33 |
|
/** |
35 |
|
- |
* if after add pDay there are insufficient days in the new month, the date will be set to the 1st of the next month. |
|
34 |
+ |
* Return T with the parameter pDay added. |
36 |
35 |
|
*/ |
37 |
36 |
|
public final T addDays( int pDays ) |
38 |
37 |
|
{ |
39 |
|
- |
return (pDays == 0) ? us() : LLsetDay( mDay + pDays, true ); |
|
38 |
+ |
return (pDays == 0) ? us() : LLsetDay( mDay + pDays ); |
40 |
39 |
|
} |
41 |
40 |
|
|
42 |
41 |
|
/** |
43 |
|
- |
* if after minus pDays there are insufficient days in the new month, the date will be set to the last day of the target month |
|
42 |
+ |
* Return T with the parameter pDay subtracted. |
44 |
43 |
|
*/ |
45 |
44 |
|
public final T minusDays( int pDays ) |
46 |
45 |
|
{ |
47 |
|
- |
return (pDays == 0) ? us() : LLsetDay( mDay - pDays, false ); |
|
46 |
+ |
return (pDays == 0) ? us() : LLsetDay( mDay - pDays ); |
|
47 |
+ |
} |
|
48 |
+ |
|
|
49 |
+ |
@Override |
|
50 |
+ |
public String toSQLvalue() |
|
51 |
+ |
{ |
|
52 |
+ |
return super.toSQLvalue() + "-" + formatDay2(); |
48 |
53 |
|
} |
49 |
54 |
|
|
50 |
55 |
|
// vvvvvvvvvvvvvvvvvv Support methods vvvvvvvvvvvvvvvvv |
51 |
56 |
|
|
|
57 |
+ |
protected final String formatDay2() |
|
58 |
+ |
{ |
|
59 |
+ |
return Integers.zeroPadIt( 2, mDay ); |
|
60 |
+ |
} |
|
61 |
+ |
|
52 |
62 |
|
protected static final int validate( int pYear, int pMonth, int pDay ) |
53 |
63 |
|
throws IllegalArgumentException |
54 |
64 |
|
{ |
|
@@ -85,16 +95,18 @@ |
85 |
95 |
|
/** |
86 |
96 |
|
* @param pNewDay != current |
87 |
97 |
|
*/ |
88 |
|
- |
abstract protected T LLsetDay( int pNewDay, boolean pAdjustForward ); |
|
98 |
+ |
abstract protected T LLsetDay( int pNewDay ); |
89 |
99 |
|
|
90 |
100 |
|
protected static class Mutable extends AbstractCalendarYM.Mutable |
91 |
101 |
|
{ |
92 |
102 |
|
private int mDay; |
|
103 |
+ |
private boolean mDayConstrained; |
93 |
104 |
|
|
94 |
|
- |
public Mutable( int pYear, int pMonth, int pDay ) |
|
105 |
+ |
public Mutable( int pYear, int pMonth, int pDay, boolean pDayConstrained ) |
95 |
106 |
|
{ |
96 |
107 |
|
super( pYear, pMonth ); |
97 |
108 |
|
mDay = pDay; |
|
109 |
+ |
mDayConstrained = pDayConstrained; |
98 |
110 |
|
} |
99 |
111 |
|
|
100 |
112 |
|
public final int getDay() |
|
@@ -147,6 +159,11 @@ |
147 |
159 |
|
{ |
148 |
160 |
|
return false; |
149 |
161 |
|
} |
|
162 |
+ |
if ( mDayConstrained ) |
|
163 |
+ |
{ |
|
164 |
+ |
mDay = zDaysInMonth; |
|
165 |
+ |
return false; |
|
166 |
+ |
} |
150 |
167 |
|
mDay -= zDaysInMonth; |
151 |
168 |
|
incrementMonth(); |
152 |
169 |
|
return true; |