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
package org.litesoft.core.typeutils.gregorian;

import java.util.*;

import org.litesoft.core.simpletypes.temporal.*;

public class Dates
{
    public static Date now()
    {
        return new Date();
    }

    public static SimpleDate forceEndOfMonth( SimpleDate pSimpleDate )
    {
        return (pSimpleDate == null) ? null : pSimpleDate.forceEndOfMonth();
    }

    /**
     * Returns null if a valid date, or error text if not!
     */
    public static String checkValidity( int pYear, int pMonth, int pDay )
    {
        Month zMonth = Month.fromMonthNumber( pMonth );
        if ( zMonth == null )
        {
            return "Invalid month: " + pMonth;
        }
        if ( pDay < 1 )
        {
            return "Invalid day: " + pDay;
        }
        int maxDaysInMonth = zMonth.daysIn( pYear );
        if ( maxDaysInMonth < pDay )
        {
            return zMonth.name() + " " + pYear + " only has " + maxDaysInMonth + ", attempted to set days to: " + pDay;
        }
        return null;
    }
}

Commits for litesoft/trunk/Java/core/Anywhere/src/org/litesoft/core/typeutils/gregorian/Dates.java

Diff revisions: vs.
Revision Author Commited Message
851 Diff Diff GeorgeS picture GeorgeS Mon 08 Oct, 2012 00:05:32 +0000

Breaking the code as Temporal changes are implemented...

823 Diff Diff GeorgeS picture GeorgeS Sun 19 Aug, 2012 16:10:13 +0000
819 GeorgeS picture GeorgeS Sat 18 Aug, 2012 18:09:40 +0000