SimpleDateFormat , , cookie , . , , GMT. GMT String.format, .
// Your values here
String name = "test";
String value = "test";
String path = "/";
int maxAge = 60;
StringBuilder sb = new StringBuilder();
sb.append(name);
sb.append("=");
sb.append(value);
sb.append("; path=");
sb.append(path);
Calendar cal = Calendar.getInstance();
cal.setTimeZone(TimeZone.getTimeZone("GMT"));
cal.add(Calendar.SECOND, maxAge);
sb.append("; Expires=");
sb.append(String.format(Locale.US, "%1$ta, %1$td-%1$tb-%1$tY %1$tH:%1$tM:%1$tS GMT", cal));
sb.append("; Max-Age=");
sb.append(maxAge);
response.setHeader("Set-Cookie", sb.toString());