Package ucar.unidata.util
Class DatePattern
java.lang.Object
ucar.unidata.util.DatePattern
handle user defined simple date/time patterns (such as yyyymm hh:nn)
- Version:
- $Revision: 1.54 $
- Author:
- Willem Nieuwenhuis
-
Nested Class Summary
Nested Classes -
Constructor Summary
ConstructorsConstructorDescriptionDatePattern
(String dmtpat) Constructor: creates a regular expression to extract a date based on a template. -
Method Summary
Modifier and TypeMethodDescriptionint
get
(char field) Retrieve the value of the field.getRegex()
Get the regular expression that is generated from the templateReturn the fields for which the template matched the search string.static void
boolean
Match a search string against the compile pattern.
-
Constructor Details
-
DatePattern
Constructor: creates a regular expression to extract a date based on a template. The template uses date/time elements only (numerically only!):- y, Y : Year
- m, M : Month
- d, D : Day
- h, H : Hour
- n, N : Minute (m is already in use for MONTH)
- s, S : Seconds
- Parameters:
dmtpat
- the user defined date/time pattern
-
-
Method Details
-
getValidFields
Return the fields for which the template matched the search string. For example the template 'yyyymm' applied to the search string 'GLR200704' will return [YEAR, MONTH].- Returns:
- The list with found fields
-
get
public int get(char field) Retrieve the value of the field. If no value was parsed the value will be -1. Recognized field values are:- YEAR
- MONTH
- DAY
- HOUR
- MINUTE
- SECOND
- Parameters:
field
- the field to retrieve the value for- Returns:
- the value of the field
-
match
Match a search string against the compile pattern.- Parameters:
search
- the search string- Returns:
- true if there is a match
-
getRegex
Get the regular expression that is generated from the template- Returns:
- The regular expression
-
getDateTime
- Returns:
- the date / time of the latest match() call
-
main
-