Class DurationUtils

java.lang.Object
org.openhab.core.util.DurationUtils

@NonNullByDefault public class DurationUtils extends Object
Static utility methods that are helpful when dealing with Duration.
Author:
Jimmy Tanagra - Initial contribution
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static Duration
    parse(String durationString)
    Parses a duration string in ISO-8601 format or a custom format like "1d 1h 15m 30s 500ms" where 'd' stands for days, 'h' for hours, 'm' for minutes, 's' for seconds, and 'ms' for milliseconds.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • DurationUtils

      public DurationUtils()
  • Method Details

    • parse

      public static Duration parse(String durationString) throws IllegalArgumentException
      Parses a duration string in ISO-8601 format or a custom format like "1d 1h 15m 30s 500ms" where 'd' stands for days, 'h' for hours, 'm' for minutes, 's' for seconds, and 'ms' for milliseconds.
      Parameters:
      durationString - the string representation of the duration
      Returns:
      a Duration object representing the parsed duration
      Throws:
      IllegalArgumentException - if the string cannot be parsed into a valid duration