Class DateNormalization


  • public class DateNormalization
    extends java.lang.Object
    Author:
    ubaldino
    • Method Summary

      Modifier and Type Method Description
      static java.lang.String format_date​(java.util.Date d)
      Format_date.
      static int getIntValue​(java.lang.String val)
      Gets the int value.
      static void normalize_date​(java.util.Map<java.lang.String,​java.lang.String> elements, DateMatch dt)
      For now this reports only DATE and standard TIME fields.
      static int normalize_day​(java.util.Map<java.lang.String,​java.lang.String> elements)
      Normalize_day.
      static int normalize_month​(java.util.Map<java.lang.String,​java.lang.String> elements)
      Normalize_month.
      static int normalize_month_name​(java.util.Map<java.lang.String,​java.lang.String> elements)
      Normalize_month_name.
      static int normalize_time​(java.util.Map<java.lang.String,​java.lang.String> elements, java.lang.String tmField)
      Given a field hh, mm, or ss, get field from map and normalize/validate the value.
      static org.joda.time.DateTimeZone normalize_tz​(java.util.Map<java.lang.String,​java.lang.String> elements)
      Z or Zulu is not always recognized as UTC / GMT+0000.
      static int normalize_year​(java.util.Map<java.lang.String,​java.lang.String> elements)
      Normalize_year.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Field Detail

      • INVALID_DATE

        public static int INVALID_DATE
      • INVALID_DAY

        public static int INVALID_DAY
      • NO_YEAR

        public static int NO_YEAR
      • NO_MONTH

        public static int NO_MONTH
      • NO_DAY

        public static int NO_DAY
    • Constructor Detail

      • DateNormalization

        public DateNormalization()
    • Method Detail

      • format_date

        public static java.lang.String format_date​(java.util.Date d)
        Format_date.
        Parameters:
        d - date obj
        Returns:
        formatted date
      • normalize_date

        public static void normalize_date​(java.util.Map<java.lang.String,​java.lang.String> elements,
                                          DateMatch dt)
                                   throws java.text.ParseException
        For now this reports only DATE and standard TIME fields. Timezone is still TODO. TODO: throw NormalizationException
        Parameters:
        elements - pattern fields
        dt - found date
        Throws:
        java.text.ParseException - the parse exception
      • normalize_tz

        public static org.joda.time.DateTimeZone normalize_tz​(java.util.Map<java.lang.String,​java.lang.String> elements)
        Z or Zulu is not always recognized as UTC / GMT+0000.
        Parameters:
        elements - pattern fields
        Returns:
        the date time zone
      • normalize_time

        public static int normalize_time​(java.util.Map<java.lang.String,​java.lang.String> elements,
                                         java.lang.String tmField)
        Given a field hh, mm, or ss, get field from map and normalize/validate the value.
        Parameters:
        elements - the elements
        tmField - the tm field
        Returns:
        the int
      • normalize_year

        public static int normalize_year​(java.util.Map<java.lang.String,​java.lang.String> elements)
        Normalize_year.
        Parameters:
        elements - all matched fields
        Returns:
        year fixed if possible, otherwise INVALID_DATE
      • normalize_month

        public static int normalize_month​(java.util.Map<java.lang.String,​java.lang.String> elements)
                                   throws java.text.ParseException
        Normalize_month.
        Parameters:
        elements - the elements
        Returns:
        the int
        Throws:
        java.text.ParseException - the parse exception
      • normalize_month_name

        public static int normalize_month_name​(java.util.Map<java.lang.String,​java.lang.String> elements)
                                        throws java.text.ParseException
        Normalize_month_name.
        Parameters:
        elements - pattern fields
        Returns:
        the month numeric
        Throws:
        java.text.ParseException - the parse exception
      • normalize_day

        public static int normalize_day​(java.util.Map<java.lang.String,​java.lang.String> elements)
        Normalize_day.
        Parameters:
        elements - pattern fields
        Returns:
        the int
      • getIntValue

        public static int getIntValue​(java.lang.String val)
        Gets the int value.
        Parameters:
        val - the val
        Returns:
        the int value