Search in sources :

Example 16 with FastDateFormat

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

the class PactDslJsonBody method time.

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

Example 17 with FastDateFormat

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

the class PactDslJsonBody method timestamp.

/**
     * Attribute that must match the given timestamp format
     * @param name attribute name
     * @param format timestamp format
     * @param example example date and time to use for generated bodies
     */
public PactDslJsonBody timestamp(String name, String format, Date example) {
    FastDateFormat instance = FastDateFormat.getInstance(format);
    body.put(name, instance.format(example));
    matchers.put(matcherKey(name), matchTimestamp(format));
    return this;
}
Also used : FastDateFormat(org.apache.commons.lang3.time.FastDateFormat)

Aggregations

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