Class DatePattern

java.lang.Object
ucar.unidata.util.DatePattern

public class DatePattern extends Object
handle user defined simple date/time patterns (such as yyyymm hh:nn)
Version:
$Revision: 1.54 $
Author:
Willem Nieuwenhuis
  • Constructor Details

    • DatePattern

      public DatePattern(String dmtpat)
      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

      public List<Character> 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

      public boolean match(String search)
      Match a search string against the compile pattern.
      Parameters:
      search - the search string
      Returns:
      true if there is a match
    • getRegex

      public String getRegex()
      Get the regular expression that is generated from the template
      Returns:
      The regular expression
    • getDateTime

      public DateTime getDateTime()
      Returns:
      the date / time of the latest match() call
    • main

      public static void main(String[] args)