Package de.murmelmeister.murmelapi.utils
Class TimeUtil
java.lang.Object
de.murmelmeister.murmelapi.utils.TimeUtil
Utility class for parsing and formatting time-based values used across the plugin.
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringformatDuration(MessageService messageService, int languageId, long totalSeconds, TimeFilterUtil... filters) Formats the supplied duration into a localized, human-readable string.static longparseDurationInSeconds(String time) Parses a short duration token (e.g.
-
Field Details
-
TIME_PATTERN
-
-
Constructor Details
-
TimeUtil
public TimeUtil()
-
-
Method Details
-
parseDurationInSeconds
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 labelslanguageId- Identifier of the target languagetotalSeconds- Duration to formatfilters- Optional time units to exclude from the output- Returns:
- Localized duration string
-