The expires
attribute of cookies should be formatted like Expires=Wed, 09 Jun 2021 10:18:14 GMT
according to the cookie specs.
I am sending cookies with a request using rest-assured, but the expiry date gets formatted like this: Expires=9/4/18 12:03 PM
I am using rest-assured's Cookie.Builder.setExpiryDate()
to create the cookie, which just accepts a java Date object as input.
Is there any way I can urge rest-assured to change the formatting of the expiry date conforming to the cookie specs?
No. because they use the following code
final SimpleDateFormat simpleDateFormat = new SimpleDateFormat();
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
builder.append(COOKIE_ATTRIBUTE_SEPARATOR).append(EXPIRES).append(EQUALS).append(simpleDateFormat.format(expiryDate));
So, what you will get is equivalent to this
Date d1 = new Date();
System.out.println(d1);
SimpleDateFormat simpleDateFormat = new SimpleDateFormat();
simpleDateFormat.setTimeZone(TimeZone.getTimeZone("GMT"));
System.out.println(simpleDateFormat.format(d1));
Output would be something like "7/10/19, 5:50 PM".
You can get the value and then format at you end.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.