Skip to content

Commit d1b84e4

Browse files
committed
[java] fixed format of expires in Cookie.toString #13927
1 parent 4e59ac8 commit d1b84e4

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

java/src/org/openqa/selenium/Cookie.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import java.util.Date;
2323
import java.util.Map;
2424
import java.util.Objects;
25+
import java.util.TimeZone;
2526
import java.util.TreeMap;
2627

2728
public class Cookie implements Serializable {
@@ -255,12 +256,12 @@ public Map<String, Object> toJson() {
255256

256257
@Override
257258
public String toString() {
259+
SimpleDateFormat sdf = new SimpleDateFormat("EEE, dd MMM yyyy HH:mm:ss z");
260+
sdf.setTimeZone(TimeZone.getTimeZone("GMT"));
258261
return name
259262
+ "="
260263
+ value
261-
+ (expiry == null
262-
? ""
263-
: "; expires=" + new SimpleDateFormat("EEE, dd MMM yyyy hh:mm:ss z").format(expiry))
264+
+ (expiry == null ? "" : "; expires=" + sdf.format(expiry))
264265
+ ("".equals(path) ? "" : "; path=" + path)
265266
+ (domain == null ? "" : "; domain=" + domain)
266267
+ (isSecure ? ";secure;" : "")

0 commit comments

Comments
 (0)