Class DateTimeValidator
java.lang.Object
io.github.perceivechuchu.datetimeutil.validator.DateTimeValidator
This class is a utility for date time validations
- Since:
- 2.1.0
- Author:
- Perceive Chuchu
-
Field Summary
FieldsModifier and TypeFieldDescriptionThe holder for all the date format list itemsprotected static StringThe location of the file that contains date format patterns -
Method Summary
Modifier and TypeMethodDescriptionGets all the date format patterns in a filestatic booleanValidates the date and time in textual format.static booleanValidates the date and time in textual format with the date format pattern to validate against.static booleanValidates the date and time in textual format with the localestatic booleanValidates the date and time in textual format with locale and the date format pattern to validate againstprotected static voidLoads date format patterns from a file
-
Field Details
-
fileLocation
The location of the file that contains date format patterns- Since:
- 2.1.0
-
dateFormats
The holder for all the date format list items- Since:
- 2.1.0
-
-
Method Details
-
isValid
Validates the date and time in textual format. This method uses the default locale -> "Locale.ENGLISH"- Parameters:
dateTimeText- the date time text to be validated- Returns:
- the boolean flag to indicate validity of the supplied datetime text
- Throws:
IllegalArgumentException- if parameter is not valid or the date string or pattern array is null- Since:
- 2.1.0
-
isValid
Validates the date and time in textual format with the locale- Parameters:
dateTimeText- the date time text to be validatedlocale- the locale for the dateTimeText value- Returns:
- the boolean flag to indicate validity of the supplied datetime text
- Throws:
IllegalArgumentException- if parameter is not valid or the date string or pattern array is null- Since:
- 2.1.0
-
isValid
Validates the date and time in textual format with the date format pattern to validate against. This method uses the default locale -> "Locale.ENGLISH"- Parameters:
dateTimeText- the date time text to be validateddateFormatPattern- the date format pattern to validate against- Returns:
- the boolean flag to indicate validity of the supplied datetime text
- Throws:
IllegalArgumentException- if parameter is not valid or the date string or pattern array is null- Since:
- 2.1.0
-
isValid
Validates the date and time in textual format with locale and the date format pattern to validate against- Parameters:
dateTimeText- the date time text to be validatedlocale- the locale for the dateTimeText valuedateFormatPattern- the date format pattern to validate against- Returns:
- the boolean flag to indicate validity of the supplied datetime text
- Throws:
IllegalArgumentException- if parameter is not valid or the date string or pattern array is null- Since:
- 2.1.0
-
loadDateFormats
protected static void loadDateFormats()Loads date format patterns from a file- Since:
- 2.1.0
-
getFileFromResourceAsStream
Gets all the date format patterns in a file- Returns:
- the list of date format patterns form a file
- Throws:
DateTimeValidationException- thrown when date format pattern file is not found.- Since:
- 2.1.0
-