cucumber - 短语日期格式的问题
问题描述
短语日期格式的问题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();
}
谁能建议如何解决这个问题?
解决方案
推荐阅读
- javascript - 验证给定格式的字符串
- django - Django 基于唯一键的连接模型
- c++ - 不能编译归并排序树结构?
- python - Tkinter 不在窗口上打印
- javascript - Laravel-Mix 与 BrowserSync 可处理除 Vue.js 组件之外的所有内容
- php - 我的验证码不起作用。警告:imagettftext():在第 35 行的 W:\domains\shop\reg\reg_captcha.php 中找不到/打开字体
- r - 如果数据来自不同的数据集,如何将 ggplots 添加到一个中?以及如何将几何功能区添加到离散数据?
- macos - 使用 Mac 时如何导出代码?
- active-directory - 无法使用 Active Directory 凭证登录到 Amazon Linux 服务器
- kubernetes - GKE 需要 prometheus-to-sd 吗?我可以删除它吗?