Package com.Ostermiller.util
Class YearExtensionAround
java.lang.Object
com.Ostermiller.util.YearExtensionAround
- All Implemented Interfaces:
YearExtensionPolicy
Extend years like '99 to 1999 based on dates around the current date.
- Since:
- ostermillerutils 1.08.00
- Author:
- Stephen Ostermiller https://ostermiller.org/contact.pl?regarding=Java+Utilities
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final YearExtensionAroundExtend a two digit year to a year in the 1900s 00 to 1900 01 to 1901 49 to 1949 50 to 1950 99 to 1999static final YearExtensionAroundExtend a two digit year to a year in the 2000s 00 to 2000 01 to 2001 49 to 2049 50 to 2050 99 to 2099static final YearExtensionAroundExtend a two digit year to the nearest year that ends in those two digits.static final YearExtensionAroundExtend a two digit year to the nearest year that ends in those two digits. -
Constructor Summary
ConstructorsConstructorDescriptionYearExtensionAround(int allowedYearsInPast) Create a year extension nearest policy with the current year taken from the system time.YearExtensionAround(int allowedYearsInPast, int currentYear) Create a year extension nearest policy with the given current year -
Method Summary
Modifier and TypeMethodDescriptionintextendYear(int twoDigitYear) Extend a two digit year to the nearest year that ends in those two digits.static final YearExtensionAroundgetLatest(int currentYear) Extend a two digit year to the nearest year that ends in those two digits.static final YearExtensionAroundgetNearest(int currentYear) Extend a two digit year to the nearest year that ends in those two digits.voidsetAllowedYearsInPast(int allowedYearsInPast) Number of years in the past to allow datesvoidsetCurrentYear(int currentYear) Set the current year.
-
Field Details
-
NEAREST
Extend a two digit year to the nearest year that ends in those two digits.When it is the year 2000:
- 50 to 1950
- 99 to 1999
- 00 to 2000
- 01 to 2001
- Since:
- ostermillerutils 1.08.00
-
LATEST
Extend a two digit year to the nearest year that ends in those two digits.When it is the year 2000:
- 01 to 1901
- 49 to 1949
- 50 to 1950
- 99 to 1999
- 00 to 2000
- Since:
- ostermillerutils 1.08.00
-
CENTURY_1900
Extend a two digit year to a year in the 1900s- 00 to 1900
- 01 to 1901
- 49 to 1949
- 50 to 1950
- 99 to 1999
- Since:
- ostermillerutils 1.08.00
-
CENTURY_2000
Extend a two digit year to a year in the 2000s- 00 to 2000
- 01 to 2001
- 49 to 2049
- 50 to 2050
- 99 to 2099
- Since:
- ostermillerutils 1.08.00
-
-
Constructor Details
-
YearExtensionAround
public YearExtensionAround(int allowedYearsInPast) Create a year extension nearest policy with the current year taken from the system time.- Since:
- ostermillerutils 1.08.00
-
YearExtensionAround
public YearExtensionAround(int allowedYearsInPast, int currentYear) Create a year extension nearest policy with the given current year- Parameters:
currentYear- full year eg 2000- Since:
- ostermillerutils 1.08.00
-
-
Method Details
-
getNearest
Extend a two digit year to the nearest year that ends in those two digits.When it is the year 2000:
- 50 to 1950
- 99 to 1999
- 00 to 2000
- 01 to 2001
- Parameters:
currentYear- the current year- Since:
- ostermillerutils 1.08.00
-
getLatest
Extend a two digit year to the nearest year that ends in those two digits.When it is the year 2000:
- 01 to 1901
- 49 to 1949
- 50 to 1950
- 99 to 1999
- 00 to 2000
- Parameters:
currentYear- the current year- Since:
- ostermillerutils 1.08.00
-
setAllowedYearsInPast
public void setAllowedYearsInPast(int allowedYearsInPast) Number of years in the past to allow dates- Parameters:
allowedYearsInPast- number between 0 and 99
-
setCurrentYear
public void setCurrentYear(int currentYear) Set the current year.- Parameters:
currentYear- full year eg 2000- Since:
- ostermillerutils 1.08.00
-
extendYear
public int extendYear(int twoDigitYear) Extend a two digit year to the nearest year that ends in those two digits.Will choose a year within 100 years of the current year. Whether the year is in the past or future is determined by how many years are allowed in the past.
- Specified by:
extendYearin interfaceYearExtensionPolicy- Parameters:
twoDigitYear- year from 0 to 99- Returns:
- Full year representation
- Since:
- ostermillerutils 1.08.00
-