-
public class PurchasesPeriod
-
-
Method Summary
Modifier and Type Method Description static PurchasesPeriodparse(@NonNull() CharSequence text)Obtains a {@code Period}from a text string such as{@code PnYnMnD}.-
-
Method Detail
-
parse
@Nullable() static PurchasesPeriod parse(@NonNull() CharSequence text)
Obtains a
{@code Period}from a text string such as{@code PnYnMnD}.This will parse the string produced by
{@code toString()}which isbased on the ISO-8601 period formats{@code PnYnMnD}and{@code PnW}.The string starts with an optional sign, denoted by the ASCII negativeor positive symbol. If negative, the whole period is negated.The ASCII letter "P" is next in upper or lower case.There are then four sections, each consisting of a number and a suffix.At least one of the four sections must be present.The sections have suffixes in ASCII of "Y", "M", "W" and "D" foryears, months, weeks and days, accepted in upper or lower case.The suffixes must occur in order.The number part of each section must consist of ASCII digits.The number may be prefixed by the ASCII negative or positive symbol.The number must parse to an
{@code int}.The leading plus/minus sign, and negative values for other units arenot part of the ISO-8601 standard. In addition, ISO-8601 does notpermit mixing between the
{@code PnYnMnD}and{@code PnW}formats.Any week-based input is multiplied by 7 and treated as a number of days.For example, the following are valid inputs:
"P2Y" -- Period.ofYears(2) "P3M" -- Period.ofMonths(3) "P4W" -- Period.ofWeeks(4) "P5D" -- Period.ofDays(5) "P1Y2M3D" -- Period.of(1, 2, 3) "P1Y2M3W4D" -- Period.of(1, 2, 25) "P-1Y2M" -- Period.of(-1, 2, 0) "-P1Y2M" -- Period.of(-1, -2, 0)- Parameters:
text- the text to parse, not null
-
-
-
-