Class DateUtility



  • public final class DateUtility
    extends java.lang.Object
    The Class DateUtility.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.Date toDate​(java.lang.String aValue, java.time.format.DateTimeFormatter[] aDateTimeFormatters)
      Parses a String to retrieve a date from it, using the provided DateTimeFormatter instances.
      • Methods inherited from class java.lang.Object

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

      • toDate

        public static java.util.Date toDate​(java.lang.String aValue,
                                            java.time.format.DateTimeFormatter[] aDateTimeFormatters)
                                     throws java.text.ParseException
        Parses a String to retrieve a date from it, using the provided DateTimeFormatter instances. The first one being able to parse a Date from the String will be used and that Date is returned. If none DateTimeFormatter instances were able to parse the provided String, then the first (as being provided in the array) DateTimeFormatter's parse exception is thrown.
        Parameters:
        aValue - The date String to be parsed.
        aDateTimeFormatters - The DateTimeFormatter instances to be tried out, starting with the first one.
        Returns:
        A Date retrieved from the given String.
        Throws:
        java.text.ParseException - Thrown in case none of the provided DateTimeFormatter instances was able to parse the string. Then the first caught ParseException is thrown.