org.salespointframework.core
Class CalendarTime

java.lang.Object
  extended by org.salespointframework.core.CalendarTime
All Implemented Interfaces:
Time

public class CalendarTime
extends java.lang.Object
implements Time

This class is an implementation of the Time interface.

The time is represented as a Gregorian Calendar.

Only a simple Adapterclass for java.util.GregorianCalendar

Since:
v2.0
Version:
2.0 29/11/2000
Author:
Thomas Medack

Field Summary
static int DATE
          Field number for setTimeToCount(int) indicates that the days will be increased by goAhead(java.lang.Object)
static int HOUR
          Field number for setTimeToCount(int) indicates that the hours will be increased by goAhead(java.lang.Object)
private  java.util.Calendar m_cCalendar
          The Calender containing the current date
private  int m_iDefaultInterval
          The default interval for timesteps
private  int m_iTimeToCount
          The field which goAhead(java.lang.Object) will increase.
static int MINUTE
          Field number for setTimeToCount(int) indicates that the minutes will be increased by goAhead(java.lang.Object)
static int MONTH
          Field number for setTimeToCount(int) indicates that the month will be increased by goAhead(java.lang.Object)
static int SECOND
          Field number for setTimeToCount(int) indicates that the seconds will be increased by goAhead(java.lang.Object)
static int YEAR
          Field number for setTimeToCount(int) indicates that the years will be increased by goAhead(java.lang.Object)
 
Constructor Summary
CalendarTime()
          Creates a new CalendarTime with the current systemtime.
CalendarTime(int year, int month, int date, int hours, int minutes, int seconds)
          Creates a new CalendarTime with the given starting time
CalendarTime(int year, int month, int date, int hours, int minutes, int seconds, int iTimeToCount)
          Creates a new CalendarTime with the given starting time and an int that defines the field which will be increased by goAhead(java.lang.Object).
CalendarTime(long lTimeInMillis)
          Creates a new CalendarTime with the given starting time.
CalendarTime(long lTimeInMillis, int iTimeToCount)
          Creates a new CalendarTime with the given starting time and an int that defines the field which will be increased by goAhead(java.lang.Object).
 
Method Summary
 java.util.Calendar getCalendar()
          Get the adapted Calendar.
private  java.lang.String getCorrectString(int iTime)
          Left-pad the given number with 0 to fill a two digit string.
 java.lang.Object getDefaultInterval()
          Get the default time interval.
 java.lang.Object getTime()
          Get the calendars date
 java.lang.Comparable<java.lang.String> getTimeStamp(long lStampNumber)
          Create and return a time stamp.
 void goAhead(java.lang.Object oInterval)
          Increment the time by the given time interval.
 void setTime(java.lang.Object oTime)
          Set the given date.
 void setTimeToCount(int iTime)
          Set an int that will define which time field will be increased by goAhead(java.lang.Object).
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

m_cCalendar

private java.util.Calendar m_cCalendar
The Calender containing the current date


m_iDefaultInterval

private int m_iDefaultInterval
The default interval for timesteps


m_iTimeToCount

private int m_iTimeToCount
The field which goAhead(java.lang.Object) will increase.

See Also:
YEAR, MONTH, DATE, HOUR, MINUTE, SECOND

SECOND

public static int SECOND
Field number for setTimeToCount(int) indicates that the seconds will be increased by goAhead(java.lang.Object)


MINUTE

public static int MINUTE
Field number for setTimeToCount(int) indicates that the minutes will be increased by goAhead(java.lang.Object)


HOUR

public static int HOUR
Field number for setTimeToCount(int) indicates that the hours will be increased by goAhead(java.lang.Object)


DATE

public static int DATE
Field number for setTimeToCount(int) indicates that the days will be increased by goAhead(java.lang.Object)


MONTH

public static int MONTH
Field number for setTimeToCount(int) indicates that the month will be increased by goAhead(java.lang.Object)


YEAR

public static int YEAR
Field number for setTimeToCount(int) indicates that the years will be increased by goAhead(java.lang.Object)

Constructor Detail

CalendarTime

public CalendarTime()
Creates a new CalendarTime with the current systemtime.


CalendarTime

public CalendarTime(long lTimeInMillis)
Creates a new CalendarTime with the given starting time.

Parameters:
lTimeInMillis - a long representing the time in milliseconds

CalendarTime

public CalendarTime(long lTimeInMillis,
                    int iTimeToCount)
Creates a new CalendarTime with the given starting time and an int that defines the field which will be increased by goAhead(java.lang.Object).

Parameters:
lTimeInMillis - a long representing the time in milliseconds
iTimeToCount - an int representing the field which will be increased by goAhead(java.lang.Object)
See Also:
YEAR, MONTH, DATE, HOUR, MINUTE, SECOND

CalendarTime

public CalendarTime(int year,
                    int month,
                    int date,
                    int hours,
                    int minutes,
                    int seconds)
Creates a new CalendarTime with the given starting time

Parameters:
year - an int representing the Year you want to start with
month - an int representing the Month you want to start with
date - an int representing the Day you want to start with
hours - an int representing the Hour you want to start with
minutes - an int representing the Minute you want to start with
seconds - an int representing the Second you want to start with

CalendarTime

public CalendarTime(int year,
                    int month,
                    int date,
                    int hours,
                    int minutes,
                    int seconds,
                    int iTimeToCount)
Creates a new CalendarTime with the given starting time and an int that defines the field which will be increased by goAhead(java.lang.Object).

Parameters:
year - an int representing the Year you want to start with
month - an int representing the Month you want to start with
date - an int representing the Day you want to start with
hours - an int representing the Hour you want to start with
minutes - an int representing the Minute you want to start with
seconds - an int representing the Second you want to start with
iTimeToCount - an int representing the field which will be increased by goAhead(java.lang.Object)
See Also:
YEAR, MONTH, DATE, HOUR, MINUTE, SECOND
Method Detail

setTime

public void setTime(java.lang.Object oTime)
             throws java.lang.IllegalArgumentException
Set the given date.

Specified by:
setTime in interface Time
Parameters:
oTime - a java.util.Date representing the date to be set
Throws:
java.lang.IllegalArgumentException - if Parameter is not a java.util.Date

setTimeToCount

public void setTimeToCount(int iTime)
Set an int that will define which time field will be increased by goAhead(java.lang.Object).

Parameters:
iTime - an int representing a constant
See Also:
YEAR, MONTH, DATE, HOUR, MINUTE, SECOND

getTime

public java.lang.Object getTime()
Get the calendars date

Specified by:
getTime in interface Time
Returns:
a java.util.Date representing the calendars date

goAhead

public void goAhead(java.lang.Object oInterval)
             throws java.lang.IllegalArgumentException
Increment the time by the given time interval.

Specified by:
goAhead in interface Time
Parameters:
oInterval - the interval by which to increment time. Must be an Integer object that gives the number of days by which to increment.
Throws:
java.lang.IllegalArgumentException - if the given interval is no Integer or is null.

getDefaultInterval

public java.lang.Object getDefaultInterval()
Get the default time interval.

Specified by:
getDefaultInterval in interface Time
Returns:
an Integer describing the default time step.

getCalendar

public java.util.Calendar getCalendar()
Get the adapted Calendar.

Returns:
a Calendar object describing the calendar of this class.

getCorrectString

private java.lang.String getCorrectString(int iTime)
Left-pad the given number with 0 to fill a two digit string.

Helper function used by getTimeStamp(long).


getTimeStamp

public java.lang.Comparable<java.lang.String> getTimeStamp(long lStampNumber)
Create and return a time stamp.

Specified by:
getTimeStamp in interface Time
Parameters:
lStampNumber - the number of the stamp
Returns:
a fresh time stamp.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
a string representation of this date.