|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--iglu.util.CalendarParser
Takes a date string, figures out what its format it, and tell you the month, date, and year numbers. Useful in database applications where users will be manually entering dates. This class lets your program support multiple date formats for entry. Also automatically adjusts for two digit year problems. If the year is entered in two digits (e.g. 99), the class will assume that the year is either 30 years in the future or seventy years in the past.
Nested Class Summary | |
class |
CalendarParser.InvalidDateFormatException
|
Field Summary | |
(package private) int |
date
Parsed day number |
(package private) java.lang.String |
dateString
The input string |
(package private) int |
month
Parsed Value of the Month |
(package private) int |
year
Parsed Year number |
Constructor Summary | |
CalendarParser(java.lang.String nDateString)
Creates new CalendarParser |
Method Summary | |
int |
date()
Returns the day of the parsed date |
protected java.lang.String |
dropLeadZero(java.lang.String s)
Protected utility to drop a zero from the front of the string. |
static void |
main(java.lang.String[] argv)
Takes a date as a parameter, and returns the month, day, and year number. |
int |
month()
Returns the month of the parsed date |
protected void |
parseAmerDate()
handles dates in the form MM/DD/YY and MM/DD/YYYY Yes, I know there is some ambiguity here. |
protected void |
parseNumberDate()
Handles dates in the form MMDDYY and MMDDYYYY |
protected void |
parseSqlDate()
Handles dates in the form YYYY-MM-DD. |
protected int |
realYear(int year)
Given a two or four digit year, converts it into the appropriate four digit year. |
int |
year()
Returns the year of the parsed date |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
int month
int date
int year
java.lang.String dateString
Constructor Detail |
public CalendarParser(java.lang.String nDateString)
nDateString
- The string version of the dateMethod Detail |
public int month()
public int date()
public int year()
protected void parseAmerDate()
protected void parseSqlDate()
protected void parseNumberDate()
protected java.lang.String dropLeadZero(java.lang.String s)
s
- protected int realYear(int year)
year
- public static void main(java.lang.String[] argv)
argv
-
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |