如何在SoapUI的日期减去天? [英] How to get in SoapUI the date minus days?

查看:156
本文介绍了如何在SoapUI的日期减去天?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在认为这是一个重复的请阅读。

Before thinking this is a duplicate please read.

我一直在阅读这里和其他地方的帖子,但无法弄清楚为什么日期在

I have been reading through the posts here and elsewhere but cannot figure out why the date is coming out invalid in the first place.

我使用SoapUI Pro进行调用,并放在XML中提交一些代码引用,以便创建过去的日期,但我需要他们相对于今天不会是未来或遥远的过去,所以我已经使用以下

I am using SoapUI Pro to make calls and have placed in the XML that submits some code reference in order to create dates in the past but I need them to be relative to today not something that will be in the future or distant past so I have used the following

${=import java.text.SimpleDateFormat;
new SimpleDateFormat("YYYY-MM-DD").format(new Date()-6);}


b $ b

当我提交对Web服务的调用时,我得到这个错误。

When I submit my call to the Web Service I get back this error.


'2016-02-32'不是date的有效值

'2016-02-32' is not a valid value for 'date'

有人可以解释为什么会发生这种情况吗?
和我需要纠正这个?

Can someone please explain why this is occurring? and what am I needing to correct this?

最终我需要做两件事。


  1. 以YYYY-MM-DD格式创建过去6天内的日期

  2. 创建日期时间,格式为YYYY-MM -DD HH:mm:ss.SSSXXX

非常感谢您的帮助。
我不使用日期?
我看到一些使用日历和新的引用Java 8,它只是一个时间紧缩的东西今天早上,我不想下来任何兔子洞跟踪可能的事情,可能是一个问题

Greatly appreciate some assistance on this. Am I not to use the Date? I have seen some that are using the Calendar and new references to Java 8, it is just a time crunch thing this morning and I did not want to go down any rabbit holes to track possible things that may be an issue as the servers are not using Java 8 at this time.

推荐答案

尝试类似这样

${=import java.text.SimpleDateFormat; Calendar cal = Calendar.getInstance(); cal.add(Calendar.DATE, -6); new SimpleDateFormat("yyyy-MM-dd").format(cal.getTime());}



you can use it as well for the date and time, just replace the formatting string.

格式化日期的corect模式为 yyyy-MM -dd (请参阅 SimpleDateFormat javadoc)

The corect pattern for formatting date is yyyy-MM-dd (see SimpleDateFormat javadoc)

  • y - means the current year
  • Y - means week year, can be different then year for the first and last week in year (explained difference)
  • d - day in month
  • D - day in year

根据如何从Java中的Date对象中减去X天?

这篇关于如何在SoapUI的日期减去天?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆