Class StaticDurationFormat
java.lang.Object
io.github.blackbaroness.durationserializer.format.impl.StaticDurationFormat
- All Implemented Interfaces:
DurationFormat
- Direct Known Subclasses:
FullWordEnglishDurationFormat,MediumLenghtRussianDurationFormat,MediumLengthEnglishDurationFormat,ShortEnglishDurationFormat,ShortRussianDurationFormat
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription@NotNull Durationdeserialize(@NotNull String unitInput, @org.jetbrains.annotations.Range(from=0L, to=9223372036854775807L) long amountInput) Parses the given string into a duration unit.@NotNull Stringserialize(@NotNull DurationUnit unit, @org.jetbrains.annotations.Range(from=0L, to=9223372036854775807L) long amount) Formats the given duration into a string.
-
Constructor Details
-
StaticDurationFormat
-
-
Method Details
-
serialize
@NotNull public @NotNull String serialize(@NotNull @NotNull DurationUnit unit, @org.jetbrains.annotations.Range(from=0L, to=9223372036854775807L) long amount) Description copied from interface:DurationFormatFormats the given duration into a string.For example, it can convert MINUTES and 5 to "5 minutes".
- Specified by:
serializein interfaceDurationFormat- Parameters:
unit- duration unitamount- duration amount- Returns:
- string representation of duration unit with specified amount
-
deserialize
@NotNull public @NotNull Duration deserialize(@NotNull @NotNull String unitInput, @org.jetbrains.annotations.Range(from=0L, to=9223372036854775807L) long amountInput) throws InvalidFormatException Description copied from interface:DurationFormatParses the given string into a duration unit.For example, it can convert "5 minutes" to
Duration.ofMinutes(5).- Specified by:
deserializein interfaceDurationFormat- Parameters:
unitInput- input string which should contain only duration unit string representationamountInput- time amount- Returns:
- parsed duration
- Throws:
InvalidFormatException- if input string is not a valid duration unit
-