Search in sources :

Example 1 with FastDateFormat

use of org.apache.commons.lang3.time.FastDateFormat in project pact-jvm by DiUS.

the class PactDslJsonArray method timestamp.

/**
     * Element that must match the given timestamp format
     * @param format timestamp format
     */
public PactDslJsonArray timestamp(String format) {
    FastDateFormat instance = FastDateFormat.getInstance(format);
    body.put(instance.format(new Date()));
    matchers.put(rootPath + appendArrayIndex(0), matchTimestamp(format));
    return this;
}
Also used : FastDateFormat(org.apache.commons.lang3.time.FastDateFormat) Date(java.util.Date)

Example 2 with FastDateFormat

use of org.apache.commons.lang3.time.FastDateFormat in project pact-jvm by DiUS.

the class PactDslJsonArray method time.

/**
     * Element that must match the given time format
     * @param format time format to match
     */
public PactDslJsonArray time(String format) {
    FastDateFormat instance = FastDateFormat.getInstance(format);
    body.put(instance.format(new Date()));
    matchers.put(rootPath + appendArrayIndex(0), matchTime(format));
    return this;
}
Also used : FastDateFormat(org.apache.commons.lang3.time.FastDateFormat) Date(java.util.Date)

Example 3 with FastDateFormat

use of org.apache.commons.lang3.time.FastDateFormat in project pact-jvm by DiUS.

the class PactDslJsonArray method time.

/**
     * Element that must match the given time format
     * @param format time format to match
     * @param example example time to use for generated bodies
     */
public PactDslJsonArray time(String format, Date example) {
    FastDateFormat instance = FastDateFormat.getInstance(format);
    body.put(instance.format(example));
    matchers.put(rootPath + appendArrayIndex(0), matchTime(format));
    return this;
}
Also used : FastDateFormat(org.apache.commons.lang3.time.FastDateFormat)

Example 4 with FastDateFormat

use of org.apache.commons.lang3.time.FastDateFormat in project pact-jvm by DiUS.

the class PactDslJsonArray method date.

/**
     * Element that must match the provided date format
     * @param format date format to match
     */
public PactDslJsonArray date(String format) {
    FastDateFormat instance = FastDateFormat.getInstance(format);
    body.put(instance.format(new Date()));
    matchers.put(rootPath + appendArrayIndex(0), matchDate(format));
    return this;
}
Also used : FastDateFormat(org.apache.commons.lang3.time.FastDateFormat) Date(java.util.Date)

Example 5 with FastDateFormat

use of org.apache.commons.lang3.time.FastDateFormat in project pact-jvm by DiUS.

the class PactDslJsonBody method date.

/**
     * Attribute that must match the provided date format
     * @param name attribute date
     * @param format date format to match
     */
public PactDslJsonBody date(String name, String format) {
    FastDateFormat instance = FastDateFormat.getInstance(format);
    body.put(name, instance.format(new Date()));
    matchers.put(matcherKey(name), matchDate(format));
    return this;
}
Also used : FastDateFormat(org.apache.commons.lang3.time.FastDateFormat) Date(java.util.Date)

Aggregations

FastDateFormat (org.apache.commons.lang3.time.FastDateFormat)17 Date (java.util.Date)8 Calendar (java.util.Calendar)1