@Retention(value=RUNTIME) @Target(value={PARAMETER,ANNOTATION_TYPE}) public @interface Format
This annotation can be specified on step definition method parameters to give Cucumber a hint about how to transform a String into an object such as a Date or a Calendar. For example, if you have the following Gherkin step with a ISO 8601 date:
Given the date is 2012-03-01T06:54:12
Then the following Java Step Definition would convert that into a Date:
@Given("^the date is (\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2})$") public void the_date_is(@Format("yyyy-MM-dd'T'HH:mm:ss") Date date) { this.date = date; }
Or a Calendar:
@Given("^the date is (\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2})$") public void the_date_is(@Format("yyyy-MM-dd'T'HH:mm:ss") Calendar cal) { this.cal = cal; }
This annotation also works for data tables that are transformed to a list of beans with Date or Calendar fields.
public abstract String value
Copyright © 2017. All Rights Reserved.