|
@@ -3,20 +3,19 @@ |
3 |
3 |
|
import org.litesoft.core.*; |
4 |
4 |
|
|
5 |
5 |
|
/** |
6 |
|
- |
* A partial date that acts as a sort of proxy for a java.util.Date (burying the deprecated method use) providing |
7 |
|
- |
* varying levels of resolution based on the DateRes. |
|
6 |
+ |
* A Calendar Year, or partial "date" with resolution only to the Year ("Wall" relative). |
8 |
7 |
|
* <p/> |
9 |
8 |
|
* Note: This class supports Gregorian dates only and has no concept of time or TimeZones. As such when working with |
10 |
9 |
|
* Java Util Date(s) (or it's descendants) the local (or "Wall") date is all that is considered! |
11 |
10 |
|
*/ |
12 |
|
- |
public final class CalendarY extends AbstractCalendarY<CalendarY> implements SQLdateable |
|
11 |
+ |
public final class CalendarY extends AbstractCalendarY<CalendarY, AbstractCalendarY.Mutable> implements SQLdateable |
13 |
12 |
|
{ |
14 |
13 |
|
private static final long serialVersionUID = 1L; |
15 |
14 |
|
|
16 |
15 |
|
@SuppressWarnings({"deprecation", "UnusedDeclaration"}) @Deprecated /** for Serialization */ |
17 |
16 |
|
protected CalendarY() |
18 |
17 |
|
{ |
19 |
|
- |
super( 0 ); |
|
18 |
+ |
this( 0 ); |
20 |
19 |
|
} |
21 |
20 |
|
|
22 |
21 |
|
public CalendarY( int pYear ) |
|
@@ -41,21 +40,19 @@ |
41 |
40 |
|
return YearFormatAccessor.get().format( this ); |
42 |
41 |
|
} |
43 |
42 |
|
|
44 |
|
- |
public static String toString( CalendarY pDate ) |
|
43 |
+ |
public static String toString( CalendarY pCalendar ) |
45 |
44 |
|
{ |
46 |
|
- |
return (pDate != null) ? pDate.toString() : null; |
|
45 |
+ |
return (pCalendar != null) ? pCalendar.toString() : null; |
47 |
46 |
|
} |
48 |
47 |
|
|
49 |
|
- |
public static String toY( CalendarY pFromY ) |
|
48 |
+ |
public static String toY( CalendarY pCalendar ) |
50 |
49 |
|
{ |
51 |
|
- |
return (pFromY != null) ? pFromY.toY() : null; |
|
50 |
+ |
return (pCalendar != null) ? pCalendar.toY() : null; |
52 |
51 |
|
} |
53 |
52 |
|
|
54 |
53 |
|
public String toY() |
55 |
54 |
|
{ |
56 |
|
- |
StringBuilder sb = new StringBuilder(); |
57 |
|
- |
yyyy_Chunk.appendYearTo( this, sb ); |
58 |
|
- |
return sb.toString(); |
|
55 |
+ |
return formatSortableDisplayFormY( this, new StringBuilder() ).toString(); |
59 |
56 |
|
} |
60 |
57 |
|
|
61 |
58 |
|
public static CalendarY fromY( String pToY ) |
|
@@ -64,6 +61,11 @@ |
64 |
61 |
|
return fromStringForm( pToY ); |
65 |
62 |
|
} |
66 |
63 |
|
|
|
64 |
+ |
public final String toSQLvalue() |
|
65 |
+ |
{ |
|
66 |
+ |
return formatSQLvalueY( this, new StringBuilder() ).toString(); |
|
67 |
+ |
} |
|
68 |
+ |
|
67 |
69 |
|
public static CalendarY fromSQLvalue( String pToSQLvalue ) |
68 |
70 |
|
{ |
69 |
71 |
|
return fromStringForm( pToSQLvalue ); |
|
@@ -71,23 +73,26 @@ |
71 |
73 |
|
|
72 |
74 |
|
private static CalendarY fromStringForm( String pStringForm ) |
73 |
75 |
|
{ |
74 |
|
- |
return pStringForm == null ? null : new CalendarY( parseInt( pStringForm.trim(), "Year", pStringForm ) ); |
|
76 |
+ |
return pStringForm == null ? null : new CalendarY( parseYear( pStringForm, pStringForm.trim() ) ); |
75 |
77 |
|
} |
76 |
78 |
|
|
77 |
79 |
|
@Override |
78 |
80 |
|
public UtilDateAdaptor toUtilDateAdaptor() |
79 |
81 |
|
{ |
80 |
|
- |
return new UtilDateAdaptor( getYear(), 1, 1 ); |
|
82 |
+ |
return UtilDateAdaptor.currentWall( getYear() ); |
81 |
83 |
|
} |
82 |
84 |
|
|
83 |
85 |
|
// vvvvvvvvvvvvvvvvvv Support methods vvvvvvvvvvvvvvvvv |
84 |
86 |
|
|
85 |
|
- |
/** |
86 |
|
- |
* @param pNewYear != current |
87 |
|
- |
*/ |
88 |
87 |
|
@Override |
89 |
|
- |
protected CalendarY LLsetYear( int pNewYear ) |
|
88 |
+ |
protected CalendarY createTypeFrom( Mutable pMutable ) |
|
89 |
+ |
{ |
|
90 |
+ |
return new CalendarY( pMutable.getYear() ); |
|
91 |
+ |
} |
|
92 |
+ |
|
|
93 |
+ |
@Override |
|
94 |
+ |
protected Mutable createMutable( int pNewYear ) |
90 |
95 |
|
{ |
91 |
|
- |
return new CalendarY( pNewYear ); |
|
96 |
+ |
return new Mutable( pNewYear ); |
92 |
97 |
|
} |
93 |
98 |
|
} |