首页 > 解决方案 > 短语日期格式的问题

问题描述

短语日期格式的问题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();
}

谁能建议如何解决这个问题?

标签: cucumbercucumber-jvmcucumber-javacucumber-junit

解决方案


推荐阅读