EMMA Coverage Report (generated Sat May 17 10:56:07 GMT 2008)
[all classes][spiffy.core.util]

COVERAGE SUMMARY FOR SOURCE FILE [DateHelper.java]

nameclass, %method, %block, %line, %
DateHelper.java100% (1/1)100% (3/3)100% (47/47)100% (11/11)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class DateHelper100% (1/1)100% (3/3)100% (47/47)100% (11/11)
DateHelper (): void 100% (1/1)100% (3/3)100% (1/1)
date (int, int, int): Date 100% (1/1)100% (22/22)100% (5/5)
date (int, int, int, int, int, int): Date 100% (1/1)100% (22/22)100% (5/5)

1package spiffy.core.util;
2 
3import java.util.Calendar;
4import java.util.Date;
5 
6/**
7 * Helper methods for creating and manipulating Dates, Calendars etc..
8 * 
9 * @since 0.2
10 * @author Kasper B. Graversen, (c) 2007
11 */
12public class DateHelper {
13        
14        /**
15         * An easy and non-depricated non-lenient way of creating Date objects.
16         * 
17         * @param year
18         *            the year, e.g. 2007 is year 2007
19         * @param month
20         *            the month, where 1 == January
21         * @param dayOfMonth
22         *            the day of the month, where 1 == first day of the month
23         * @return a Date object with time set to midnight, ie. hour = 00, minutes = 00, seconds = 00 and milis = 000
24         * @since 0.02
25         */
26        public static Date date(final int year, final int month, final int dayOfMonth) {
27                final Calendar cal = Calendar.getInstance();
28                cal.setLenient(false);
29                cal.set(year, month - 1, dayOfMonth, 0, 0, 0);
30                cal.set(Calendar.MILLISECOND, 0);
31                return cal.getTime();
32        }
33        
34        /**
35         * An easy and non-depricated non-lenient way of creating Date objects.
36         * 
37         * @param year
38         *            the year, e.g. 2007 is year 2007
39         * @param month
40         *            the month, where 1 == January
41         * @param dayOfMonth
42         *            the day of the month, where 1 == first day of the month
43         * @param hour
44         *            the hour in 24 hour format where 0 == midnight
45         * @param minute
46         *            is the minute 0-59
47         * @param second
48         *            is the seconds 0-59
49         * @return a Date object with time set to midnight, ie. hour = 00, minutes = 00, seconds = 00 and milis = 000
50         * @since 0.02
51         */
52        public static Date date(final int year, final int month, final int dayOfMonth, final int hour, final int minute,
53                        final int second) {
54                final Calendar cal = Calendar.getInstance();
55                cal.setLenient(false);
56                cal.set(year, month - 1, dayOfMonth, hour, minute, second);
57                cal.set(Calendar.MILLISECOND, 0);
58                return cal.getTime();
59        }
60        
61}

[all classes][spiffy.core.util]
EMMA 2.0.5312 (C) Vladimir Roubtsov