Class MDfromHTMLDuration

    • Constructor Detail

      • MDfromHTMLDuration

        public MDfromHTMLDuration()
        Construct an undefinedMDfromHTMLDuration.
      • MDfromHTMLDuration

        public MDfromHTMLDuration​(String strName)
        Construct a well formedMDfromHTMLDuration
        Parameters:
        strName - name of this duration
      • MDfromHTMLDuration

        public MDfromHTMLDuration​(String strName,
                                  MDfromHTMLDate dateStart,
                                  MDfromHTMLDate dateEnd)
        Construct a well formedMDfromHTMLDuration
        Parameters:
        strName - name of this duration
        dateStart - start date of this duration
        dateEnd - end date of this duration
    • Method Detail

      • elapsedDays

        public static long elapsedDays​(Date dateStart,
                                       Date dateEnd)
        Calculate the number of elapsed days between the start and end of this duration. If no end date has been set, then the duration is 0L. If no start date has been set, then the duration is the number of days since the epoch (midnight 1/1/70 GMT) until the end date. If the start date is greater than the end date, then 0L is returned.
        Parameters:
        dateStart - the start date of the duration
        dateEnd - the end date of the duration
        Returns:
        the number of elapsed days between the start and end of this duration.
      • elapsedHours

        public static long elapsedHours​(Date dateStart,
                                        Date dateEnd)
        Calculate the number of elapsed hours between the start and end of this duration. If no end date has been set, then the duration is 0L. If no start date has been set, then the duration is the number of hours since the epoch (midnight 1/1/70 GMT) until the end date. If the start date is greater than the end date, then 0L is returned.
        Parameters:
        dateStart - the start date of the duration
        dateEnd - the end date of the duration
        Returns:
        the number of elapsed hours between the start and end of this duration.
      • elapsedMinutes

        public static long elapsedMinutes​(Date dateStart,
                                          Date dateEnd)
        Calculate the number of elapsed minutes between the start and end of this duration. If no end date has been set, then the duration is 0L. If no start date has been set, then the duration is the number of minutes since the epoch (midnight 1/1/70 GMT) until the end date. If the start date is greater than the end date, then 0L is returned.
        Parameters:
        dateStart - the start date of the duration
        dateEnd - the end date of the duration
        Returns:
        the number of elapsed minutes between the start and end of this duration.
      • elapsedSeconds

        public static long elapsedSeconds​(Date dateStart,
                                          Date dateEnd)
        Calculate the number of elapsed seconds between the start and end of this duration. If no end date has been set, then the duration is 0L. If no start date has been set, then the duration is the number of seconds since the epoch (midnight 1/1/70 GMT) until the end date. If the start date is greater than the end date, then 0L is returned.
        Parameters:
        dateStart - the start date of the duration
        dateEnd - the end date of the duration
        Returns:
        the number of elapsed seconds between the start and end of this duration.
      • elapsedTime

        public static long elapsedTime​(Date dateStart,
                                       Date dateEnd)
        Calculate the number of elapsed milliseconds between the start and end of this duration. If no end date has been set, then the duration is 0L. If no start date has been set, then the duration is the number of milliseconds since the epoch (midnight 1/1/70 GMT) until the end date. If the start date is greater than the end date, then the negative of the elapsed time from the end date to the start date is returned.
        Parameters:
        dateStart - the start date of the duration
        dateEnd - the end date of the duration
        Returns:
        the number of elapsed milliseconds between the start and end of this duration.
      • formattedElapsedTime

        public static String formattedElapsedTime​(Date dateStart,
                                                  Date dateEnd)
      • formattedElapsedTime

        public static String formattedElapsedTime​(double dElapsedSeconds)
      • formattedElapsedTime

        public static String formattedElapsedTime​(long lElapsedMS)
      • main

        public static void main​(String[] args)
      • newInstanceFromListString

        public static MDfromHTMLDuration newInstanceFromListString​(String listString)
                                                            throws Exception
        Create anMDfromHTMLDuration from the passed list string.
        Parameters:
        listString - the list of String fields needed to create anMDfromHTMLDuration (name, start date, end date);
        Returns:
        a newly createdMDfromHTMLDuration object filled with the content of the supplied listString. If the listString is null or empty, or does not contain at least the name field, an undefinedMDfromHTMLDuration is returned.
        Throws:
        Exception - if listString is null or empty, or if the name in the list is null, empty or undefined.
        See Also:
        isUndefined()
      • undefinedForNull

        public static MDfromHTMLDuration undefinedForNull​(MDfromHTMLDuration duration)
        Converts the inputMDfromHTMLDuration to an undefinedMDfromHTMLDuration if the input MDfromHTMLDuration is null.
        Parameters:
        duration - MDfromHTMLDuration to be tested against null and converted.
        Returns:
        An undefinedMDfromHTMLDuration if the inputMDfromHTMLDuration was null, otherwise, the inputMDfromHTMLDuration is echoed back.
      • elapsedDays

        public long elapsedDays()
        Calculate the number of elapsed days between the start and end of this duration. If no end date has been set, then the duration is 0L. If no start date has been set, then the duration is the number of days since the epoch (midnight 1/1/70 GMT) until the end date. If the start date is greater than the end date, then 0L is returned.
        Returns:
        the number of elapsed days between the start and end of this duration.
      • elapsedHours

        public long elapsedHours()
        Calculate the number of elapsed hours between the start and end of this duration. If no end date has been set, then the duration is 0L. If no start date has been set, then the duration is the number of hours since the epoch (midnight 1/1/70 GMT) until the end date. If the start date is greater than the end date, then 0L is returned.
        Returns:
        the number of elapsed hours between the start and end of this duration.
      • elapsedMinutes

        public long elapsedMinutes()
        Calculate the number of elapsed minutes between the start and end of this duration. If no end date has been set, then the duration is 0L. If no start date has been set, then the duration is the number of minutes since the epoch (midnight 1/1/70 GMT) until the end date. If the start date is greater than the end date, then 0L is returned.
        Returns:
        the number of elapsed minutes between the start and end of this duration.
      • elapsedSeconds

        public long elapsedSeconds()
        Calculate the number of elapsed seconds between the start and end of this duration. If no end date has been set, then the duration is 0L. If no start date has been set, then the duration is the number of seconds since the epoch (midnight 1/1/70 GMT) until the end date. If the start date is greater than the end date, then 0L is returned.
        Returns:
        the number of elapsed seconds between the start and end of this duration.
      • elapsedTime

        public long elapsedTime()
        Calculate the number of elapsed milliseconds between the start and end of this duration. If no end date has been set, then the duration is 0L. If no start date has been set, then the duration is the number of milliseconds since the epoch (midnight 1/1/70 GMT) until the end date. If the start date is greater than the end date, then 0L is returned.
        Returns:
        the number of elapsed milliseconds between the start and end of this duration.
      • formattedElapsedTime

        public String formattedElapsedTime()
        Returns:
        the elapsed time of this duration formatted as a String containing an optional sign (if the duration is negative) followed by the days-hours:minutes:seconds.milliseconds
      • isUndefined

        public boolean isUndefined()
        Determine if thisMDfromHTMLDuration is undefined (e.g., if its name equals UNDEFINED_String).
        Returns:
        true if thisMDfromHTMLDuration is determined to be undefined. Otherwise, return false.
        See Also:
        MDfromHTMLConstants.UNDEFINED_String
      • setEndDate

        public void setEndDate​(MDfromHTMLDate endDate)
        Set the end date for this duration. If null is passed, the endDate is set to an undefinedMDfromHTMLDate.
        Parameters:
        endDate - the end date.
      • setStartDate

        public void setStartDate​(MDfromHTMLDate startDate)
        Set the start date for this duration. If null is passed, the startDate is set to an undefinedMDfromHTMLDate.
        Parameters:
        startDate - the start date.
      • toString

        public String toString()
        Generates a list string compatible with the Utils listStringToArrayList method describing this duration.
        Overrides:
        toString in class Object
        Returns:
        a string list comprising delimited, quoted fields containing the name, start date, and end date of this duration, as well as the elapsed time formatted as DD-HH:MM:SS.mmm where DD is the number of days, HH is the number of hours, MM is the number of minutes, SS is the number of seconds, and mmm is the number of milliseconds.
        See Also:
        MDfromHTMLUtils.listStringToArrayList(String)
      • toString

        public String toString​(String strTimeZone)
        Generates a list string compatible with the Utils listStringToArrayList method describing this duration using the specified timezone for dates.
        Parameters:
        strTimeZone - the ID for a TimeZone as a String containing a sign followed by the two digit hour and two digit minute offset from Greenwich Mean Time. For example, for Eastern Standard Time, submit "-0500". For Europe/Paris submit "+0100".
        Returns:
        a string list comprising delimited, quoted fields containing the name, start date, and end date of this duration, as well as the elapsed time formatted as DD-HH:MM:SS.mmm where DD is the number of days, HH is the number of hours, MM is the number of minutes, SS is the number of seconds, and mmm is the number of milliseconds.
        See Also:
        MDfromHTMLUtils.listStringToArrayList(String)