public class Validity
extends java.lang.Object
Modifier and Type | Field and Description |
---|---|
private java.util.Calendar |
m_validFrom |
private java.util.Calendar |
m_validTo |
private static int |
TEMPORARY_VALIDITY_IN_MINUTES
This is the minimal time (in minutes) for a validity created by
createValidTo().
|
Constructor and Description |
---|
Validity(java.util.Calendar a_validFrom,
java.util.Calendar a_validTo)
Creates a new Validity.
|
Validity(java.util.Calendar a_validFrom,
int a_validityInYears)
Creates a new Validity.
|
Modifier and Type | Method and Description |
---|---|
private static java.util.Calendar |
createValidTo(java.util.Calendar a_validFrom,
int a_validityInYears)
For a given Calendar object that represents a start date (valid from), this method
creates an end date (valid to) that lies a specified amount of years ahead from the start
date.
|
java.util.Date |
getValidFrom()
Returns the first valid date in the validity period.
|
java.util.Date |
getValidTo()
Returns the last valid date in the validity period.
|
boolean |
isValid(java.util.Date a_date)
Checks if the given date is contained in the validity period.
|
private java.util.Calendar m_validFrom
private java.util.Calendar m_validTo
private static final int TEMPORARY_VALIDITY_IN_MINUTES
public Validity(java.util.Calendar a_validFrom, int a_validityInYears)
a_validFrom
- a Calendar object that represents a start datea_validityInYears
- an amount of years that the created date should lie ahead from the
start date; if the amount is less than 0 the created date will
only be ahead from the start date for a very small time
(some minutes)java.lang.IllegalArgumentException
- if the calendar is nullpublic Validity(java.util.Calendar a_validFrom, java.util.Calendar a_validTo)
a_validFrom
- a Calendar object that represents a start datea_validTo
- a Calendar object that represents a end date; if the date lies before
the start date it will be set equal to the start datejava.lang.IllegalArgumentException
- if on of the calendars is nullpublic java.util.Date getValidFrom()
public java.util.Date getValidTo()
public boolean isValid(java.util.Date a_date)
a_date
- a Dateprivate static java.util.Calendar createValidTo(java.util.Calendar a_validFrom, int a_validityInYears)
a_validFrom
- a Calendar object that represents a start datea_validityInYears
- an amount of years that the created date should lie ahead from the
start date; if the amount is less than 0 the created date will
only be ahead from the start date for a very small time
(some minutes)Copyright © 2023. All rights reserved.