Class TemporalAmountParser<T extends TemporalAmount>

java.lang.Object
dev.rollczi.litecommands.time.TemporalAmountParser<T>
Type Parameters:
T - type of temporal amount (must be Duration or Period or subclass of TemporalAmount)
Direct Known Subclasses:
DurationParser, PeriodParser

public abstract class TemporalAmountParser<T extends TemporalAmount> extends Object
This class is used to parse temporal amount from string and format it to string. It can parse both Period and Duration.

It can parse both estimated and exact temporal amount. Estimated temporal amount is a temporal amount that is not exact. For example, if you want to parse 1 month, you can write 1mo or 30d. If you write 1mo, it can be estimated to 28, 29, 30 or 31 days. If you write 1y, it can be estimated to 365 or 366 days.

This class is immutable. You can create new instance using constructor PeriodParser() or DurationParser(). You can also use DurationParser.DATE_TIME_UNITS, PeriodParser.DATE_UNITS and DurationParser.TIME_UNITS. You can add new units using withUnit(String, ChronoUnit).

Use parse(String) to parse temporal amount from string. Use format(TemporalAmount) to format temporal amount to string.