Class TimeUtil

java.lang.Object
de.murmelmeister.murmelapi.utils.TimeUtil

public final class TimeUtil extends Object
Utility class for parsing and formatting time-based values used across the plugin.
  • Field Details

    • TIME_PATTERN

      private static final Pattern TIME_PATTERN
  • Constructor Details

    • TimeUtil

      public TimeUtil()
  • Method Details

    • parseDurationInSeconds

      public static long parseDurationInSeconds(String time)
      Parses a short duration token (e.g. 5m, 2h) into seconds.
      Parameters:
      time - Duration token to parse
      Returns:
      Parsed seconds, or a negative sentinel value if the input is invalid
    • formatDuration

      public static String formatDuration(MessageService messageService, int languageId, long totalSeconds, TimeFilterUtil... filters)
      Formats the supplied duration into a localized, human-readable string.

      Filters act as an exclusion list: any listed units are omitted from the result.

      Parameters:
      messageService - Service used to resolve localized unit labels
      languageId - Identifier of the target language
      totalSeconds - Duration to format
      filters - Optional time units to exclude from the output
      Returns:
      Localized duration string