Class CqlDurationLiteralParser

java.lang.Object
org.evomaster.client.java.controller.cassandra.parser.CqlDurationLiteralParser

public class CqlDurationLiteralParser extends Object
Parses a Cassandra duration string literal into a CqlDurationLiteral.

Supports four formats, all optionally prefixed with - for a negative duration, mirroring com.datastax.oss.driver.api.core.data.CqlDuration#from(String):

  • Standard Cassandra: 1y2mo3w4d5h6m7s (units, including weeks, may appear in any order)
  • ISO 8601: P1Y2M3DT4H5M6S
  • ISO 8601, weeks only: P3W
  • ISO 8601, alternative format: P0001-02-03T04:05:06
  • Method Details

    • parse

      public static CqlDurationLiteral parse(String stringDuration)
      Parses a CQL duration literal into a CqlDurationLiteral. A leading - is stripped and applied as a sign to all three components. The remainder is dispatched to the matching pattern-specific parser by parseUnsigned(java.lang.String).
      Parameters:
      stringDuration - the duration literal to parse; must not be null, empty, or blank
      Returns:
      the parsed duration, decomposed into months, days and nanoseconds
      Throws:
      IllegalArgumentException - if stringDuration is null, empty, or blank