Subversion Repository Public Repository

litesoft

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

Diff revisions: vs.
  @@ -35,32 +35,78 @@
35 35 return TemporalResolution.ToMonth;
36 36 }
37 37
38 - /**
39 - * @param pNewYear != mYear
40 - */
41 38 @Override
42 - protected CalendarYM LLsetYear( int pNewYear, boolean pAdjustForward )
39 + public String toString()
43 40 {
44 - return new CalendarYM( pNewYear, getMonth() );
41 + return YearMonthFormatAccessor.get().format( this );
42 + }
43 +
44 + public static String toString( CalendarYM pDate )
45 + {
46 + return (pDate != null) ? pDate.toString() : null;
47 + }
48 +
49 + public static String toYM( CalendarYM pFromYM )
50 + {
51 + return (pFromYM != null) ? pFromYM.toYM() : null;
52 + }
53 +
54 + public String toYM()
55 + {
56 + StringBuilder sb = new StringBuilder();
57 + yyyy_Chunk.appendYearTo( this, sb );
58 + sb.append( '/' );
59 + MM_Chunk.appendMonthTo( this, sb );
60 + return sb.toString();
61 + }
62 +
63 + public static CalendarYM fromYM( String pToYM )
64 + throws IllegalArgumentException
65 + {
66 + return fromStringForm( pToYM, "/" );
67 + }
68 +
69 + public static CalendarYM fromSQLvalue( String pToSQLvalue )
70 + {
71 + return fromStringForm( pToSQLvalue, "-" );
72 + }
73 +
74 + private static CalendarYM fromStringForm( String pStringForm, String pSequentialSeperators )
75 + {
76 + if ( pStringForm == null )
77 + {
78 + return null;
79 + }
80 + String[] parts = SimpleParser.parse( pStringForm, pSequentialSeperators, 2 );
81 + return new CalendarYM( parseInt( parts[0], "Year", pStringForm ), //
82 + parseInt( parts[1], "Month", pStringForm ) );
45 83 }
46 84
47 85 @Override
48 - protected CalendarYM LLsetMonth( int pNewMonth, boolean pAdjustForward )
86 + public UtilDateAdaptor toUtilDateAdaptor()
49 87 {
50 - Mutable zMutable = new Mutable( getYear(), pNewMonth );
51 - zMutable.normalize();
52 - return new CalendarYM( zMutable.getYear(), zMutable.getMonth() );
88 + return new UtilDateAdaptor( getYear(), getMonth(), 1 );
53 89 }
54 90
91 + // vvvvvvvvvvvvvvvvvv Support methods vvvvvvvvvvvvvvvvv
92 +
93 + /**
94 + * @param pNewYear != current
95 + */
55 96 @Override
56 - public String toString()
97 + protected CalendarYM LLsetYear( int pNewYear )
57 98 {
58 - return super.toString(); //To change body of overridden methods use File | Settings | File Templates.
99 + return new CalendarYM( pNewYear, getMonth() );
59 100 }
60 101
102 + /**
103 + * @param pNewMonth != current
104 + */
61 105 @Override
62 - public String toSQLvalue()
106 + protected CalendarYM LLsetMonth( int pNewMonth )
63 107 {
64 - return null; //To change body of implemented methods use File | Settings | File Templates.
108 + Mutable zMutable = new Mutable( getYear(), pNewMonth );
109 + zMutable.normalize();
110 + return new CalendarYM( zMutable.getYear(), zMutable.getMonth() );
65 111 }
66 112 }