Subversion Repository Public Repository

litesoft

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
package org.litesoft.core.simpletypes.temporal;

import org.litesoft.core.*;

/**
 * A Calendar Year & Month, or partial "date" with resolution of Year and Month ("Wall" relative).
 * <p/>
 * Note: This class supports Gregorian dates only and has no concept of time or TimeZones.  As such when working with
 * Java Util Date(s) (or it's descendants) the local (or "Wall") date is all that is considered!
 */
@SuppressWarnings("UnusedDeclaration")
public final class CalendarYM extends AbstractCalendarYM<CalendarYM, AbstractCalendarYM.Mutable> implements SQLdateable
{
    private static final long serialVersionUID = 1L;

    private int mYear, mMonth;

    @Override
    public int getYear()
    {
        return mYear;
    }

    @Override
    public int getMonth()
    {
        return mMonth;
    }

    public CalendarYM( int pYear, int pMonth )
    {
        mMonth = validateMonth( mYear = pYear, pMonth);
    }

    @SuppressWarnings({"deprecation", "UnusedDeclaration"}) @Deprecated /** for Serialization */
    protected CalendarYM()
    {
        this( 0, 0 );
    }

    public CalendarYM( CalendarAccessorYM pAccessor )
    {
        this( pAccessor.getYear(), pAccessor.getMonth() );
    }

    @Override
    public TemporalResolution getResolution()
    {
        return TemporalResolution.ToMonth;
    }

    @Override
    public String toString()
    {
        return YearMonthFormatAccessor.get().format( this );
    }

    public static String toString( CalendarYM pCalendar )
    {
        return (pCalendar != null) ? pCalendar.toString() : null;
    }

    public static String toYM( CalendarYM pCalendar )
    {
        return (pCalendar != null) ? pCalendar.toYM() : null;
    }

    public String toYM()
    {
        return formatSortableDisplayFormYM( this, new StringBuilder() ).toString();
    }

    public static CalendarYM fromYM( String pToYM )
            throws IllegalArgumentException
    {
        return fromStringForm( pToYM, "/" );
    }

    public final String toSQLvalue()
    {
        return formatSQLvalueYM( this, new StringBuilder() ).toString();
    }

    public static CalendarYM fromSQLvalue( String pToSQLvalue )
    {
        return fromStringForm( pToSQLvalue, "-" );
    }

    private static CalendarYM fromStringForm( String pStringForm, String pSequentialSeperators )
    {
        String[] parts = parseSimple( pStringForm, pSequentialSeperators );
        return (parts == null) ? null : //
               new CalendarYM( parseYear( pStringForm, parts ), //
                               parseMonth( pStringForm, parts ) );
    }

    @Override
    public UtilDateAdaptor toUtilDateAdaptor()
    {
        return UtilDateAdaptor.wall( getYear(), getMonth() );
    }

    // vvvvvvvvvvvvvvvvvv Support methods vvvvvvvvvvvvvvvvv

    @Override
    protected CalendarYM createTypeFrom( Mutable pMutable )
    {
        return new CalendarYM( pMutable.getYear(), pMutable.getMonth() );
    }

    @Override
    protected Mutable createMutable( int pYear, int pNewMonth )
    {
        return new Mutable( pYear, pNewMonth );
    }
}

Commits for litesoft/trunk/Java/core/Anywhere/src/org/litesoft/core/simpletypes/temporal/CalendarYM.java

Diff revisions: vs.
Revision Author Commited Message
898 Diff Diff GeorgeS picture GeorgeS Sun 17 Mar, 2013 21:46:33 +0000

Temporal!!!

897 Diff Diff GeorgeS picture GeorgeS Mon 25 Feb, 2013 02:04:34 +0000
893 Diff Diff GeorgeS picture GeorgeS Mon 14 Jan, 2013 01:18:30 +0000
864 Diff Diff GeorgeS picture GeorgeS Mon 19 Nov, 2012 01:48:25 +0000
862 Diff Diff GeorgeS picture GeorgeS Thu 15 Nov, 2012 02:23:36 +0000

On the Way...

861 Diff Diff GeorgeS picture GeorgeS Mon 05 Nov, 2012 13:55:32 +0000
859 GeorgeS picture GeorgeS Mon 05 Nov, 2012 01:26:38 +0000