以短语日期格式发布

时间:2018-12-19 13:29:39

标签: cucumber cucumber-jvm cucumber-java cucumber-junit

以短语日期格式YYYY-MM-DD

发布

通用实用程序:

 public boolean validateDateFormatfortedthb(String datetd,String dateFormat) {
        DateFormat ddf = new SimpleDateFormat("yyyy-MM-dd",Locale.UK);
//      DateFormat df = new SimpleDateFormat(dateFormatT,Locale.UK);
        try{
            Date valuationDate = ddf.parse(datetd.trim()); // gives you java.util.Date

            return true;
        }catch(ParseException parseEx){
            parseEx.printStackTrace();
            return false;
        }
} 

调用功能为:

@And("^validate the valuation date format for nav is \\\"([^\\\"]*)\\\" in JSON$")
    public void validateDateFieldOfNavFeedw(String dateFormat) throws IOException {
        JSONObject jsonObject = new JSONObject(CommonVariables.outputMessageJson);
        JSONObject headerSec = jsonObject.getJSONObject("domainHeader");
        String datetd = headerSec.getString("valuationDate");
        Assert.assertEquals(true,
                commonUtilities.validateDateFormatfortedthb(datetd, dateFormat));

    }

获取错误消息为:

@Then("^validate the valuation date format for nav is \"([^\"]*)\" in JSON$")
public void validate_the_valuation_date_format_for_nav_is_in_JSON(String arg1) throws Throwable {
    // Write code here that turns the phrase above into concrete actions
    throw new PendingException();
}

有人可以建议如何解决此问题吗?

0 个答案:

没有答案