Java tutorial
//package com.java2s; //License from project: Open Source License import java.text.SimpleDateFormat; import java.util.Date; import java.util.Locale; import java.util.TimeZone; public class Main { public static String formatDateForCookie(Date date) { // for http cookie final String PATTERN_RFC1123 = "EEE, dd MMM yyyy HH:mm:ss zzz"; SimpleDateFormat format = new SimpleDateFormat(PATTERN_RFC1123, Locale.US); format.setTimeZone(TimeZone.getTimeZone("GMT")); return format.format(date); } }