Subversion Repository Public Repository

litesoft

Diff Revisions 859 vs 862 for /trunk/Java/core/Anywhere/src/org/litesoft/core/simpletypes/temporal/AbstractCalendarYM.java

Diff revisions: vs.
  @@ -6,7 +6,7 @@
6 6 {
7 7 private static final long serialVersionUID = 1L;
8 8
9 - private final int mMonth;
9 + private /* final */ int mMonth;
10 10
11 11 protected AbstractCalendarYM( int pYear, int pMonth )
12 12 {
  @@ -21,33 +21,43 @@
21 21 }
22 22
23 23 /**
24 - * Return a T with the Month set to the parameter, this is accomplished by utilizing addMonths or minusMonths as is appropriate (with their day
25 - * adjusting logic if appropriate).
24 + * Return a T with the Month set to the parameter, if there are insufficient days in the new month, the date will be set to the last day of the target month.
26 25 */
27 26 public final T month( int pMonth )
28 27 {
29 28 validateMonth( getYear(), pMonth );
30 - return (mMonth == pMonth) ? us() : (pMonth > mMonth) ? LLsetMonth( pMonth, true ) : LLsetMonth( pMonth, false );
29 + return (mMonth == pMonth) ? us() : LLsetMonth( pMonth );
31 30 }
32 31
33 32 /**
34 - * if after add pMonth there are insufficient days in the new month, the date will be set to the 1st of the next month.
33 + * if after add pMonth there are insufficient days in the new month, the date will be set to the last day of the target month.
35 34 */
36 35 public final T addMonths( int pMonths )
37 36 {
38 - return (pMonths == 0) ? us() : LLsetMonth( mMonth + pMonths, true );
37 + return (pMonths == 0) ? us() : LLsetMonth( mMonth + pMonths );
39 38 }
40 39
41 40 /**
42 - * if after minus pMonths there are insufficient days in the new month, the date will be set to the last day of the target month
41 + * if after minus pMonths there are insufficient days in the new month, the date will be set to the last day of the target month.
43 42 */
44 43 public final T minusMonths( int pMonths )
45 44 {
46 - return (pMonths == 0) ? us() : LLsetMonth( mMonth - pMonths, false );
45 + return (pMonths == 0) ? us() : LLsetMonth( mMonth - pMonths );
46 + }
47 +
48 + @Override
49 + public String toSQLvalue()
50 + {
51 + return super.toSQLvalue() + "-" + formatMonth2();
47 52 }
48 53
49 54 // vvvvvvvvvvvvvvvvvv Support methods vvvvvvvvvvvvvvvvv
50 55
56 + protected final String formatMonth2()
57 + {
58 + return Integers.zeroPadIt( 2, mMonth );
59 + }
60 +
51 61 protected static final int validateMonth( int pYear, int pMonth )
52 62 throws IllegalArgumentException
53 63 {
  @@ -84,7 +94,7 @@
84 94 /**
85 95 * @param pNewMonth != current
86 96 */
87 - abstract protected T LLsetMonth( int pNewMonth, boolean pAdjustForward );
97 + abstract protected T LLsetMonth( int pNewMonth );
88 98
89 99 protected static class Mutable
90 100 {