de.webdings.tools.time

Class EasyDate


public class EasyDate
extends java.lang.Object

EasyDate is a wrapper for java.util.Calendar and its subclasses to provide easy date-representing functionality. By default it wraps a java.util.GregorianCalendar

Version:
1.0 23.05.2005

Author:
Stefan Thesing
Website: http://www.webdings.de

See Also:
java.util.Calendar, java.util.GregorianCalendar, EasyDateCreateException

Constructor Summary

EasyDate()
constructs an EasyDate object wrapping a java.util.GregorianCalendar initialized at the moment of this constructor's call.
EasyDate(Calendar cal)
constructs an EasyDate object wrapping the specified calendar.
EasyDate(int year, int month, int day)
constructs an EasyDate object wrapping a java.util.GregorianCalendar of the specified year, month and day.

Method Summary

Calendar
getCal()
int
getDay()
int
getMonth()
int
getYear()
void
setCal(Calendar cal)

Constructor Details

EasyDate

public EasyDate()
constructs an EasyDate object wrapping a java.util.GregorianCalendar initialized at the moment of this constructor's call. Essentially, an object constructed by this constructor represents today.


EasyDate

public EasyDate(Calendar cal)
constructs an EasyDate object wrapping the specified calendar.

Parameters:
cal - The calendar to be wrapped. The constructor accepts any subclass of java.util.Calendar


EasyDate

public EasyDate(int year,
                int month,
                int day)
            throws EasyDateCreateException
constructs an EasyDate object wrapping a java.util.GregorianCalendar of the specified year, month and day.

IMPORTANT: note that unlike in java.util.GregorianCalendar's constructors January is represented by 1 and not by 0! So the months are represented according to the following table:

int #represented month
1January
2February
3March
4April
5May
6June
7July
8August
9September
10October
11November
12December

Parameters:
year - the year
month - the month
day - the day

Throws:
EasyDateCreateException - when an invalid month value is specified

Method Details

getCal

public Calendar getCal()

Returns:
the wrapped calendar.


getDay

public int getDay()

Returns:
the java.util.Calendar.DAY_OF_MONTH field of the wrapped calendar


getMonth

public int getMonth()

Returns:
the java.util.Calendar.MONTH field of the wrapped calendar


getYear

public int getYear()

Returns:
the java.util.Calendar.YEAR field of the wrapped calendar


setCal

public void setCal(Calendar cal)

Parameters:
cal - The calender to be wrapped.


EasyDate.java - Copyright (c) 2005 by Stefan Thesing

This file is part of Webdings Tools.

Webdings Tools is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version.

Webdings Tools is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License along with Webdings Tools; if not, write to the
Free Software Foundation, Inc.,
51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA



© 2005 by Stefan Thesing;
Verbatim copying and redistribution of this entire page are permitted provided this notice is preserved.